当前位置: 首页>>代码示例>>PHP>>正文


PHP cache::byKey方法代码示例

本文整理汇总了PHP中cache::byKey方法的典型用法代码示例。如果您正苦于以下问题:PHP cache::byKey方法的具体用法?PHP cache::byKey怎么用?PHP cache::byKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cache的用法示例。


在下文中一共展示了cache::byKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cron

 public static function cron()
 {
     $now = date('Y-m-d H:i:s', strtotime('-1 second', strtotime(date('Y-m-d H:i:s'))));
     $lastDatetime = cache::byKey('sarah::lastRetrievalInternalEvent', $now);
     foreach (internalEvent::getNewInternalEvent('sarah') as $internalEvent) {
         if (in_array($internalEvent->getEvent(), array('update::interactQuery'))) {
             foreach (sarah::byType('sarah') as $sarah) {
                 if ($sarah->ping()) {
                     log::add('sarah', 'info', 'Mise à jour de la grammaire de Sarah');
                     $sarah->updateSrvSarah();
                 } else {
                     cache::save('sarah::lastRetrievalInternalEvent', $lastDatetime, 0);
                 }
             }
         }
     }
 }
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:17,代码来源:sarah.class.php

示例2: getWeatherFromYahooXml

 public function getWeatherFromYahooXml()
 {
     if ($this->getConfiguration('city') == '') {
         return false;
     }
     $cache = cache::byKey('yahooWeatherXml' . $this->getConfiguration('city'));
     if ($cache->getValue() === '' || $cache->getValue() == 'false') {
         $request = new com_http('http://weather.yahooapis.com/forecastrss?w=' . urlencode($this->getConfiguration('city')) . '&u=c');
         $xmlMeteo = $request->exec(5000, 0);
         cache::set('yahooWeatherXml' . $this->getConfiguration('city'), $xmlMeteo, 7200);
     } else {
         $xmlMeteo = $cache->getValue();
     }
     return self::parseXmlWeather($xmlMeteo);
 }
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:15,代码来源:weather.class.php

示例3: 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();
 }
开发者ID:saez0pub,项目名称:core,代码行数:56,代码来源:market.class.php

示例4: execute

 public function execute($_options = null)
 {
     $xPLinstance = XPLInstance::getXPLInstance(false);
     $source = $xPLinstance->getThisDevice()->deviceName();
     $_target = $this->getEqLogic()->getLogicalId();
     if ($_options != null) {
         switch ($this->getType()) {
             case 'action':
                 switch ($this->getSubType()) {
                     case 'slider':
                         $body = str_replace('#slider#', $_options['slider'], $this->getConfiguration('xPLbody'));
                         break;
                     case 'color':
                         $body = str_replace('#color#', $_options['color'], $this->getConfiguration('xPLbody'));
                         break;
                     case 'message':
                         $replace = array('#title#', '#message#');
                         $replaceBy = array($_options['title'], $_options['message']);
                         if ($_options['message'] == '' || $_options['title'] == '') {
                             throw new Exception('[xPL] Le message et le sujet ne peuvent être vide');
                         }
                         $body = str_replace($replace, $replaceBy, $this->getConfiguration('xPLbody'));
                         break;
                 }
                 break;
         }
     }
     $message = '';
     switch ($this->getConfiguration('xPLtypeCmd')) {
         case 'XPL-CMND':
             $message .= "xpl-cmnd\n";
             break;
         case 'XPL-STAT':
             $message .= "xpl-stat\n";
             break;
         case 'XPL-TRIG':
             $message .= "xpl-trig\n";
             break;
         default:
             return "";
     }
     $message .= "{\n";
     $message .= "hop=1\n";
     $message .= sprintf("source=%s\n", $source);
     $message .= sprintf("target=%s\n", $_target);
     $message .= "}\n";
     $message .= $this->getConfiguration('xPLschema') . "\n";
     $message .= "{\n";
     $message .= $body;
     $message .= "}\n";
     $xPLinstance->sendPlainTextMessage($message);
     if ($this->getType() == 'info') {
         $mc = cache::byKey('xpl' . $this->getId());
         return $mc->getValue();
     }
     return '';
 }
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:57,代码来源:xpl.class.php

示例5: TIME

 if (init('action') == 'MigrateArduidom') {
     if (arduidom::MigrateDatas() == 1) {
         ajax::success();
     } else {
         ajax::error("Une erreur est survenue pendant la Migration des données Arduidom !");
     }
 }
 if (init('action') == 'LearnRadio') {
     $text = '';
     $etat = '';
     cache::set('arduidom_radio_learn', 1);
     $RadioLastCode = cache::byKey('arduidom_radio_lastcode');
     $RadioLastCode = $RadioLastCode->getValue();
     $RadioRepeats = cache::byKey('arduidom_radio_index');
     $RadioRepeats = $RadioRepeats->getValue();
     $RadioLeanMode = cache::byKey('arduidom_radio_learn');
     $RadioLeanMode = $RadioLeanMode->getValue();
     $text = 'UNIX TIME (for debug):' . time() . "\n" . "\n";
     $text = $text . "Mode Apprentissage : " . $RadioLeanMode . " \n";
     if ($RadioRepeats < 3) {
         $text = $text . "Appuyer sur la touche " . (3 - $RadioRepeats) . " fois avec une pause de 3 à 5 secondes entre chaque appui.\n";
         if ($RadioLastCode != '') {
             $text = $text . "Code recu : " . $RadioLastCode . "\n";
         }
     } else {
         $text = $text . "Copiez ce code dans la valeur : " . $RadioLastCode . " OK \n";
         $text = $text . "Vous pouvez fermer la fenetre. \n";
         $etat = "[END SUCCESS]\n";
         cache::set('arduidom_radio_index', 0);
         cache::set('arduidom_radio_learn', 0);
     }
开发者ID:cedric222,项目名称:arduidom,代码行数:31,代码来源:arduidom.ajax.php

示例6: pull

 public static function pull()
 {
     $cache = cache::byKey('zwave::lastUpdate');
     $http = new com_http(self::makeBaseUrl() . '/ZWaveAPI/Data/' . $cache->getValue(strtotime(date('Y-m-d H:i:s')) - 86400));
     $results = json_decode(self::handleError($http->exec()), true);
     if (is_array($results)) {
         foreach ($results as $key => $result) {
             switch ($key) {
                 case 'controller.data.controllerState':
                     nodejs::pushUpdate('zwave::' . $key, $result['value']);
                     break;
                 case 'controller.data.lastExcludedDevice':
                     if ($result['value'] != null) {
                         nodejs::pushNotification('Razberry', 'Un périphérique Z-Wave vient d\'être exclu. Logical ID : ' . $result['value']);
                         self::syncEqLogicWithRazberry();
                     }
                     break;
                 case 'controller.data.lastIncludedDevice':
                     if ($result['value'] != null) {
                         nodejs::pushNotification('Razberry', 'Un périphérique Z-Wave vient d\'être inclu. Logical ID : ' . $result['value']);
                         self::syncEqLogicWithRazberry();
                     }
                     break;
                 default:
                     $explodeKey = explode('.', $key);
                     if (count($explodeKey) > 5) {
                         $nodeId = intval($explodeKey[1]);
                         $instanceId = intval($explodeKey[3]);
                         $class = intval($explodeKey[5]);
                         for ($i = 0; $i < 6; $i++) {
                             array_shift($explodeKey);
                         }
                         $attribut = implode('.', $explodeKey);
                         foreach (self::byLogicalId($nodeId, 'zwave') as $eqLogic) {
                             foreach ($eqLogic->getCmd() as $cmd) {
                                 if ($cmd->getConfiguration('instanceId') == $instanceId && $cmd->getConfiguration('class') == '0x' . dechex($class)) {
                                     $configurationValue = $cmd->getConfiguration('value');
                                     if (strpos($configurationValue, '[') !== false && strpos($configurationValue, ']') !== false) {
                                         $configurationValue = str_replace(']', '', str_replace('[', '.', $configurationValue));
                                     }
                                     if (strpos($configurationValue, $attribut) !== false) {
                                         if (isset($result['val'])) {
                                             $value = zwaveCmd::handleResult($result['val']);
                                         } else {
                                             if (isset($result['level'])) {
                                                 $value = zwaveCmd::handleResult($result['level']);
                                             } else {
                                                 $value = zwaveCmd::handleResult($result);
                                             }
                                         }
                                         if ($value === '') {
                                             log::add('zwave', 'info', 'Event sur ' . $cmd->getId() . ' / ' . $cmd->getName() . ' mais aucun valeur trouvée. Event result :' . print_r($result, true));
                                             $value = $cmd->execute();
                                         }
                                         $cmd->event($value);
                                     }
                                 }
                             }
                         }
                     }
                     break;
             }
         }
     }
     if (isset($results['updateTime']) && is_numeric($results['updateTime']) && $results['updateTime'] > $cache->getValue(0)) {
         cache::set('zwave::lastUpdate', $results['updateTime'], 0);
     }
 }
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:68,代码来源:zwave.class.php

示例7: toHtml

 public function toHtml($_version = 'dashboard')
 {
     if ($this->getIsEnable() != 1) {
         return '';
     }
     if (!$this->hasRight('r')) {
         return '';
     }
     $version = jeedom::versionAlias($_version);
     if ($this->getDisplay('hideOn' . $version) == 1) {
         return '';
     }
     $mc = cache::byKey('sonosWidget' . $_version . $this->getId());
     if ($mc->getValue() != '') {
         return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
     }
     $replace = array('#id#' => $this->getId(), '#info#' => isset($info) ? $info : '', '#name#' => $this->getName(), '#eqLink#' => $this->hasRight('w') ? $this->getLinkToConfiguration() : '#', '#text_color#' => $this->getConfiguration('text_color'), '#background_color#' => '#5d9cec', '#hideThumbnail#' => 0, '#object_name#' => '', '#version#' => $_version, '#style#' => '', '#uid#' => 'sonos' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER);
     if ($_version == 'dview' || $_version == 'mview') {
         $object = $this->getObject();
         $replace['#name#'] = is_object($object) ? $object->getName() . ' - ' . $replace['#name#'] : $replace['#name#'];
     }
     if (($_version == 'dview' || $_version == 'mview') && $this->getDisplay('doNotShowNameOnView') == 1) {
         $replace['#name#'] = '';
     }
     if (($_version == 'mobile' || $_version == 'dashboard') && $this->getDisplay('doNotShowNameOnDashboard') == 1) {
         $replace['#name#'] = '';
     }
     $cmd_state = $this->getCmd(null, 'state');
     if (is_object($cmd_state)) {
         $replace['#state#'] = $cmd_state->execCmd(null, 2);
         if ($replace['#state#'] == __('Lecture', __FILE__)) {
             $replace['#state_nb#'] = 1;
         } else {
             $replace['#state_nb#'] = 0;
         }
     }
     foreach ($this->getCmd('action') as $cmd) {
         $replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
         if ($_version != 'mobile' && $_version != 'mview' && $cmd->getLogicalId() == 'play_playlist') {
             $replace['#playlist#'] = $cmd->getDisplay('title_possibility_list');
         }
         if ($_version != 'mobile' && $_version != 'mview' && $cmd->getLogicalId() == 'play_radio') {
             $replace['#radio#'] = $cmd->getDisplay('title_possibility_list');
         }
     }
     foreach ($this->getCmd('info') as $cmd) {
         $replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
         $replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd(null, 2);
     }
     if ($replace['#mute_state#'] == 1) {
         $replace['#mute_id#'] = $replace['#unmute_id#'];
     }
     $cmd_track_artist = $this->getCmd(null, 'track_artist');
     if (is_object($cmd_track_artist)) {
         $replace['#title#'] = $cmd_track_artist->execCmd(null, 2);
     }
     $cmd_track_album = $this->getCmd(null, 'track_album');
     if (is_object($cmd_track_album)) {
         $replace['#title#'] .= ' - ' . $cmd_track_album->execCmd(null, 2);
     }
     $replace['#title#'] = trim(trim(trim($replace['#title#']), ' - ' . __('Aucun', __FILE__)));
     $cmd_track_title = $this->getCmd(null, 'track_title');
     if (is_object($cmd_track_title)) {
         $replace['#title#'] .= ' - ' . $cmd_track_title->execCmd(null, 2);
     }
     $replace['#title#'] = trim(trim(trim($replace['#title#']), '-'));
     if (strlen($replace['#title#']) > 12) {
         $replace['#title#'] = '<marquee behavior="scroll" direction="left" scrollamount="2">' . $replace['#title#'] . '</marquee>';
     }
     if ($_version != 'mobile' && $_version != 'mview') {
         $replace['#queue#'] = str_replace("'", "\\'", $this->getConfiguration('queue'));
         $replace['#speakers#'] = str_replace("'", "\\'", $this->getConfiguration('speakers'));
     }
     $cmd_track_image = $this->getCmd(null, 'track_image');
     if (is_object($cmd_track_image)) {
         $img = dirname(__FILE__) . '/../../../../plugins/sonos3/sonos_' . $this->getId() . '.jpg';
         if (file_exists($img) && filesize($img) > 500) {
             $replace['#thumbnail#'] = 'plugins/sonos3/sonos_' . $this->getId() . '.jpg?' . md5($cmd_track_image->execCmd(null, 2));
         } else {
             $replace['#thumbnail#'] = 'plugins/sonos3/doc/images/sonos3_alt_icon.png';
         }
     }
     $parameters = $this->getDisplay('parameters');
     if (is_array($parameters)) {
         foreach ($parameters as $key => $value) {
             $replace['#' . $key . '#'] = $value;
         }
     }
     $_version = jeedom::versionAlias($_version);
     $html = template_replace($replace, getTemplate('core', $_version, 'eqLogic', 'sonos3'));
     cache::set('sonosWidget' . $_version . $this->getId(), $html, 0);
     return $html;
 }
开发者ID:eliovir,项目名称:plugin-sonos,代码行数:93,代码来源:sonos3.class.php

示例8: toHtml

 public function toHtml($_version = 'dashboard')
 {
     if ($this->getIsEnable() != 1) {
         return '';
     }
     if (!$this->hasRight('r')) {
         return '';
     }
     $_version = jeedom::versionAlias($_version);
     if ($this->getDisplay('hideOn' . $_version) == 1) {
         return '';
     }
     $mc = cache::byKey('weatherWidget' . $_version . $this->getId());
     if ($mc->getValue() != '') {
         return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
     }
     $html_forecast = '';
     if ($_version != 'mobile' || $this->getConfiguration('fullMobileDisplay', 0) == 1) {
         $forcast_template = getTemplate('core', $_version, 'forecast', 'weather');
         for ($i = 0; $i < 5; $i++) {
             $replace = array();
             $replace['#day#'] = date_fr(date('l', strtotime('+' . $i . ' days')));
             if ($i == 0) {
                 $temperature_min = $this->getCmd(null, 'temperature_min');
             } else {
                 $temperature_min = $this->getCmd(null, 'temperature_' . $i . '_min');
             }
             $replace['#low_temperature#'] = is_object($temperature_min) ? $temperature_min->execCmd() : '';
             if ($i == 0) {
                 $temperature_max = $this->getCmd(null, 'temperature_max');
             } else {
                 $temperature_max = $this->getCmd(null, 'temperature_' . $i . '_max');
             }
             $replace['#hight_temperature#'] = is_object($temperature_max) ? $temperature_max->execCmd() : '';
             $replace['#tempid#'] = is_object($temperature_max) ? $temperature_max->getId() : '';
             if ($i == 0) {
                 $condition = $this->getCmd(null, 'condition');
             } else {
                 $condition = $this->getCmd(null, 'condition_' . $i);
             }
             $replace['#icone#'] = is_object($condition) ? self::getIconFromCondition($condition->execCmd()) : '';
             $replace['#conditionid#'] = is_object($condition) ? $condition->getId() : '';
             $html_forecast .= template_replace($replace, $forcast_template);
         }
     }
     $replace = array('#id#' => $this->getId(), '#city#' => $this->getConfiguration('city_name'), '#collectDate#' => '', '#background_color#' => $this->getBackgroundColor($_version), '#eqLink#' => $this->hasRight('w') ? $this->getLinkToConfiguration() : '#', '#forecast#' => $html_forecast, '#uid#' => 'weather' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER);
     $temperature = $this->getCmd(null, 'temperature');
     $replace['#temperature#'] = is_object($temperature) ? $temperature->execCmd() : '';
     $replace['#tempid#'] = is_object($temperature) ? $temperature->getId() : '';
     $humidity = $this->getCmd(null, 'humidity');
     $replace['#humidity#'] = is_object($humidity) ? $humidity->execCmd() : '';
     $pressure = $this->getCmd(null, 'pressure');
     $replace['#pressure#'] = is_object($pressure) ? $pressure->execCmd() : '';
     $replace['#pressureid#'] = is_object($pressure) ? $pressure->getId() : '';
     $wind_speed = $this->getCmd(null, 'wind_speed');
     $replace['#windspeed#'] = is_object($wind_speed) ? $wind_speed->execCmd() : '';
     $replace['#windid#'] = is_object($wind_speed) ? $wind_speed->getId() : '';
     $sunrise = $this->getCmd(null, 'sunrise');
     $replace['#sunrise#'] = is_object($sunrise) ? $sunrise->execCmd() : '';
     $replace['#sunid#'] = is_object($sunrise) ? $sunrise->getId() : '';
     if (strlen($replace['#sunrise#']) == 3) {
         $replace['#sunrise#'] = substr($replace['#sunrise#'], 0, 1) . ':' . substr($replace['#sunrise#'], 1, 2);
     } else {
         if (strlen($replace['#sunrise#']) == 4) {
             $replace['#sunrise#'] = substr($replace['#sunrise#'], 0, 2) . ':' . substr($replace['#sunrise#'], 2, 2);
         }
     }
     $sunset = $this->getCmd(null, 'sunset');
     $replace['#sunset#'] = is_object($sunset) ? $sunset->execCmd() : '';
     if (strlen($replace['#sunset#']) == 3) {
         $replace['#sunset#'] = substr($replace['#sunset#'], 0, 1) . ':' . substr($replace['#sunset#'], 1, 2);
     } else {
         if (strlen($replace['#sunset#']) == 4) {
             $replace['#sunset#'] = substr($replace['#sunset#'], 0, 2) . ':' . substr($replace['#sunset#'], 2, 2);
         }
     }
     $wind_direction = $this->getCmd(null, 'wind_direction');
     $replace['#wind_direction#'] = is_object($wind_direction) ? $wind_direction->execCmd() : 0;
     $refresh = $this->getCmd(null, 'refresh');
     $replace['#refresh_id#'] = is_object($refresh) ? $refresh->getId() : '';
     $condition = $this->getCmd(null, 'condition_now');
     $sunset_time = is_object($sunset) ? $sunset->execCmd() : null;
     $sunrise_time = is_object($sunrise) ? $sunrise->execCmd() : null;
     if (is_object($condition)) {
         $replace['#icone#'] = self::getIconFromCondition($condition->execCmd(), $sunrise_time, $sunset_time);
         $replace['#condition#'] = $condition->execCmd();
         $replace['#conditionid#'] = $condition->getId();
         $replace['#collectDate#'] = $condition->getCollectDate();
     } else {
         $replace['#icone#'] = '';
         $replace['#condition#'] = '';
         $replace['#collectDate#'] = '';
     }
     $parameters = $this->getDisplay('parameters');
     if (is_array($parameters)) {
         foreach ($parameters as $key => $value) {
             $replace['#' . $key . '#'] = $value;
         }
     }
     $html = template_replace($replace, getTemplate('core', $_version, 'current', 'weather'));
//.........这里部分代码省略.........
开发者ID:eliovir,项目名称:plugin-weather,代码行数:101,代码来源:weather.class.php

示例9: toHtml

 public function toHtml($_version = 'dashboard')
 {
     if ($this->getIsEnable() != 1) {
         return '';
     }
     if (!$this->hasRight('r')) {
         return '';
     }
     $version = jeedom::versionAlias($_version);
     if ($this->getDisplay('hideOn' . $version) == 1) {
         return '';
     }
     $mc = cache::byKey('porkfolioWidget' . jeedom::versionAlias($_version) . $this->getId());
     if ($mc->getValue() != '') {
         return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
     }
     $background = $this->getBackgroundColor($_version);
     if ($this->getCmd(null, 'derniervers')->execCmd() < 0) {
         $humeur = 'triste';
     } else {
         $humeur = 'content';
     }
     if ($this->getCmd(null, 'somme')->execCmd() >= $this->getCmd(null, 'objectif')->execCmd()) {
         $humeur = 'jeedom';
         $background = '#34a729';
     }
     if ($this->getCmd(null, 'somme')->execCmd() == 0) {
         $background = '#e54016';
         $humeur = 'very_triste';
     }
     $replace = array('#name#' => $this->getName(), '#id#' => $this->getId(), '#background_color#' => $background, '#uid#' => 'porkfolio' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, '#eqLink#' => $this->getLinkToConfiguration(), '#porky_humeur#' => $humeur);
     foreach ($this->getCmd('info') as $cmd) {
         $replace['#' . $cmd->getLogicalId() . '_history#'] = '';
         if ($cmd->getIsVisible() == 1) {
             $replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
             if ($cmd->getName() == 'Date dépot' || $cmd->getName() == 'Date retournement' || $cmd->getName() == 'Date mouvement') {
                 $replace['#' . $cmd->getLogicalId() . '#'] = date("d/m/y H:i:s", $cmd->execCmd());
             } else {
                 $replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd();
             }
             $replace['#' . $cmd->getLogicalId() . '_collect#'] = $cmd->getCollectDate();
             if ($cmd->getIsHistorized() == 1) {
                 $replace['#' . $cmd->getLogicalId() . '_history#'] = 'history cursor';
             }
         } else {
             $replace['#' . $cmd->getLogicalId() . '#'] = '';
         }
     }
     $refresh = $this->getCmd(null, 'refresh');
     $replace['#refresh_id#'] = $refresh->getId();
     $parameters = $this->getDisplay('parameters');
     if (is_array($parameters)) {
         foreach ($parameters as $key => $value) {
             $replace['#' . $key . '#'] = $value;
         }
     }
     $html = template_replace($replace, getTemplate('core', $_version, 'porkfolio', 'porkfolio'));
     cache::set('porkfolioWidget' . $_version . $this->getId(), $html, 0);
     return $html;
 }
开发者ID:jeedom,项目名称:plugin-porkfolio,代码行数:60,代码来源:porkfolio.class.php

示例10: isset

     $orderByCaterogy = isset($params['orderByCaterogy']) && $params['orderByCaterogy'] == 1 ? true : false;
     $jsonrpc->makeSuccess(utils::o2a(plugin::listPlugin($activateOnly, $orderByCaterogy)));
 }
 /*             * ************************Object*************************** */
 if ($jsonrpc->getMethod() == 'object::all') {
     $jsonrpc->makeSuccess(utils::o2a(object::all()));
 }
 if ($jsonrpc->getMethod() == 'object::byId') {
     $object = object::byId($params['id']);
     if (!is_object($object)) {
         throw new Exception('Objet introuvable : ' . $params['id'], -32601);
     }
     $jsonrpc->makeSuccess(utils::o2a($object));
 }
 if ($jsonrpc->getMethod() == 'object::full') {
     $cache = cache::byKey('api::object::full');
     $cron = cron::byClassAndFunction('object', 'fullData');
     if (!is_object($cron)) {
         $cron = new cron();
     }
     $cron->setClass('object');
     $cron->setFunction('fullData');
     $cron->setSchedule('* * * * * 2000');
     $cron->setTimeout(10);
     $cron->save();
     if (!$cron->running()) {
         $cron->run(true);
     }
     if ($cache->getValue() != '') {
         $jsonrpc->makeSuccess(json_decode($cache->getValue(), true));
     }
开发者ID:GaelGRIFFON,项目名称:core,代码行数:31,代码来源:jeeApi.php

示例11: foreach

    log::add('arduidom', 'info', 'Radio Code = ' . $code_radio);
    log::add('arduidom', 'info', 'Learning Mode = ' . $ApprentissageRadio);
    $RadioCacheId = cache::byKey('arduidom_radio_index');
    $RadioCacheId = $RadioCacheId->getValue();
    $RadioCacheLastCode = cache::byKey('arduidom_radio_lastcode');
    $RadioCacheLastCode = $RadioCacheLastCode->getValue();
    log::add('arduidom', 'info', "READ CACHE arduidom_radio_lastcode=" . $RadioCacheLastCode);
    if ($RadioCacheId == '' || $RadioCacheLastCode != $code_radio) {
        $RadioCacheId = 0;
    }
    log::add('arduidom', 'debug', '===============CACHE============== index:' . $RadioCacheId);
    $RadioCacheId++;
    cache::set('arduidom_radio_index', $RadioCacheId);
    log::add('arduidom', 'info', "Write CACHE arduidom_radio_lastcode=" . $code_radio);
    cache::set('arduidom_radio_lastcode', $code_radio);
    $RadioCacheLastCode = cache::byKey('arduidom_radio_lastcode');
    $RadioCacheLastCode = $RadioCacheLastCode->getValue();
    log::add('arduidom', 'info', "READ CACHE arduidom_radio_lastcode=" . $RadioCacheLastCode);
}
// **** ACTIONS SUR LES DONNEES **** //
foreach (eqLogic::byType('arduidom') as $eqLogic) {
    foreach ($eqLogic->getCmd('info') as $cmd) {
        $pin_nb = $cmd->getLogicalId();
        if ($pin_nb == 999 && $code_radio != '' && $ApprentissageRadio != "1") {
            // Cherche les cmd Arduidom avec la pin 999 (RADIO VIRTUEL)
            $valueToCheck = $cmd->getConfiguration('value');
            //log::add('arduidom','debug', '===============TEST============== compare ' . $valueToCheck . ' & ' . $code_radio);
            if ($valueToCheck == $code_radio) {
                if (is_object($cmd)) {
                    log::add('arduidom', 'debug', 'Arduino n°' . $id . ' Action (Reception Radio) sur ' . $cmd->getHumanName());
                    $daemon_path = realpath(dirname(__FILE__) . '/../../core/php');
开发者ID:cedric222,项目名称:arduidom,代码行数:31,代码来源:jeeArduidom.php

示例12: preSave

 /**
  * Traitement des actions au moment de l'enregistrement de l'objet plugin
  * @return void
  */
 public function preSave()
 {
     // création du repertoire cache s'il n'existe pas //
     if (!file_exists(GCALENDAR_CACHE_PATH)) {
         if (mkdir(GCALENDAR_CACHE_PATH) === true) {
             log::add('gCalendar', 'info', '[' . $this->getId() . '] preSave():' . __("Le répertoire suivant vient d'être créé", __FILE__) . ': ' . GCALENDAR_CACHE_PATH);
         } else {
             log::add('gCalendar', 'error', '[' . $this->getId() . '] preSave(): ' . __("Le répertoire suivant n'a pas put être créé", __FILE__) . ': ' . GCALENDAR_CACHE_PATH);
             throw new Exception(__("Le répertoire suivant n'a pas put être créé", __FILE__) . ': ' . GCALENDAR_CACHE_PATH);
         }
     }
     // suppression pour raffraichissement du widget //
     $mc = cache::byKey('gcalendarWidgetmobile' . $this->getId());
     $mc->remove();
     $mc = cache::byKey('gcalendarWidgetdashboard' . $this->getId());
     $mc->remove();
 }
开发者ID:Masterfion,项目名称:plugin-gCalendar,代码行数:21,代码来源:gCalendar.class.php

示例13: pull

 public static function pull()
 {
     foreach (self::listServerZway() as $serverID => $server) {
         if (!isset($server['name'])) {
             continue;
         }
         if (!isset(self::$_zwaveUpdatetime[$serverID])) {
             $cache = cache::byKey('zwave::lastUpdate' . $serverID);
             self::$_zwaveUpdatetime[$serverID] = $cache->getValue(0);
         }
         $results = self::callRazberry('/ZWaveAPI/Data/' . self::$_zwaveUpdatetime[$serverID], $serverID);
         if (!is_array($results)) {
             continue;
         }
         foreach ($results as $key => $result) {
             if ($key == 'controller.data.controllerState') {
                 nodejs::pushUpdate('zwave::' . $key, array('name' => $server['name'], 'state' => $result['value'], 'serverId' => $serverID));
             } else {
                 if ($key == 'controller.data.lastExcludedDevice') {
                     if ($result['value'] != null) {
                         nodejs::pushUpdate('zwave::' . $key, array('name' => $server['name'], 'state' => 0, 'serverId' => $serverID));
                         nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Un périphérique Z-Wave vient est en cours d\'exclusion. Logical ID : ', __FILE__) . $result['value']));
                         sleep(5);
                         self::syncEqLogicWithRazberry($serverID);
                         nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => ''));
                     }
                 } else {
                     if ($key == 'controller.data.lastIncludedDevice') {
                         if ($result['value'] != null) {
                             nodejs::pushUpdate('zwave::' . $key, array('name' => $server['name'], 'state' => 0, 'serverId' => $serverID));
                             $eqLogic = self::getEqLogicByLogicalIdAndServerId($result['value'], $serverID);
                             if (!is_object($eqLogic)) {
                                 nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Nouveau module Z-Wave détecté. Début de l\'intégration', __FILE__)));
                                 sleep(5);
                                 self::syncEqLogicWithRazberry($serverID);
                             }
                         }
                     } else {
                         if ($key == 'controller') {
                             if (isset($result['controllerState'])) {
                                 nodejs::pushUpdate('zwave::controller.data.controllerState', array('name' => $server['name'], 'state' => $result['controllerState']['value'], 'serverId' => $serverID));
                             }
                             if (isset($result['lastIncludedDevice']) && $result['lastIncludedDevice']['value'] != null) {
                                 $eqLogic = self::getEqLogicByLogicalIdAndServerId($result['value'], $serverID);
                                 if (!is_object($eqLogic)) {
                                     nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Nouveau module Z-Wave détecté. Début de l\'intégration', __FILE__)));
                                     sleep(5);
                                     self::syncEqLogicWithRazberry($serverID);
                                 }
                             }
                             if (isset($result['lastExcludedDevice']) && $result['lastExcludedDevice']['value'] != null) {
                                 nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Un périphérique Z-Wave vient d\'être exclu. Logical ID : ', __FILE__) . $result['value']));
                                 sleep(5);
                                 self::syncEqLogicWithRazberry($i);
                             }
                         } else {
                             if ($key == 'devices') {
                                 foreach ($result as $device_id => $data) {
                                     $eqLogic = self::getEqLogicByLogicalIdAndServerId($device_id, $serverID);
                                     if (is_object($eqLogic)) {
                                         if ($eqLogic->getConfiguration('device') == 'fibaro.fgs221.pilote') {
                                             foreach ($eqLogic->searchCmdByConfiguration('pilotWire', 'info') as $cmd) {
                                                 $cmd->event($cmd->getPilotWire(), 0);
                                                 break;
                                             }
                                             continue;
                                         }
                                         foreach ($eqLogic->getCmd('info') as $cmd) {
                                             $class_id = hexdec($cmd->getConfiguration('class'));
                                             $instance_id = $cmd->getConfiguration('instanceId', 0);
                                             if (isset($data['instances'][$instance_id]['commandClasses'][$class_id])) {
                                                 $data_values = explode('.', str_replace(array(']', '['), array('', '.'), $cmd->getConfiguration('value')));
                                                 $value = $data['instances'][$instance_id]['commandClasses'][$class_id];
                                                 foreach ($data_values as $data_value) {
                                                     if (isset($value[$data_value])) {
                                                         $value = $value[$data_value];
                                                     }
                                                 }
                                                 if (!isset($value['updateTime']) || $value['updateTime'] >= $cache->getValue(0)) {
                                                     $cmd->handleUpdateValue($value);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 $explodeKey = explode('.', $key);
                                 if (!isset($explodeKey[1])) {
                                     continue;
                                 }
                                 if ($explodeKey[1] == 1) {
                                     if (isset($results['devices.1.instances.0.commandClasses.' . $explodeKey[5] . '.data.srcNodeId'])) {
                                         $explodeKey[1] = $results['devices.1.instances.0.commandClasses.' . $explodeKey[5] . '.data.srcNodeId']['value'];
                                         $eqLogic = self::getEqLogicByLogicalIdAndServerId($results['devices.1.instances.0.commandClasses.' . $explodeKey[5] . '.data.srcNodeId']['value'], $serverID);
                                         if (is_object($eqLogic)) {
                                             foreach ($eqLogic->getCmd('info') as $cmd) {
                                                 if ($cmd->getConfiguration('instanceId') == $explodeKey[3]) {
                                                     try {
                                                         $cmd->forceUpdate();
                                                     } catch (Exception $e) {
//.........这里部分代码省略.........
开发者ID:ksoul78,项目名称:plugin-zwave,代码行数:101,代码来源:zwave.class.php

示例14: toHtml

 public function toHtml($_version = 'dashboard')
 {
     if ($this->getIsEnable() != 1) {
         return '';
     }
     if (!$this->hasRight('r')) {
         return '';
     }
     $_version = jeedom::versionAlias($_version);
     if ($this->getDisplay('hideOn' . $_version) == 1) {
         return '';
     }
     $mc = cache::byKey('networksWidget' . $_version . $this->getId());
     if ($mc->getValue() != '') {
         return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
     }
     $replace = array('#name#' => $this->getName(), '#id#' => $this->getId(), '#background_color#' => '#bdc3c7', '#eqLink#' => $this->hasRight('w') ? $this->getLinkToConfiguration() : '#', '#uid#' => 'networks' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER);
     foreach ($this->getCmd('info') as $cmd) {
         $replace['#' . $cmd->getLogicalId() . '_history#'] = '';
         $replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
         $replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd(null, 2);
         if ($cmd->getSubType() == 'numeric' && $replace['#' . $cmd->getLogicalId() . '#'] === '') {
             $replace['#' . $cmd->getLogicalId() . '#'] = 0;
         }
         $replace['#' . $cmd->getLogicalId() . '_collect#'] = $cmd->getCollectDate();
         if ($cmd->getIsHistorized() == 1) {
             $replace['#' . $cmd->getLogicalId() . '_history#'] = 'history cursor';
         }
     }
     $replace['#action#'] = '';
     foreach ($this->getCmd('action') as $cmd) {
         if ($cmd->getLogicalId() == 'refresh') {
             continue;
         }
         $replace['#action#'] .= $cmd->toHtml($_version, '', '#7f8c8d');
     }
     $refresh = $this->getCmd(null, 'refresh');
     if (is_object($refresh)) {
         $replace['#refresh_id#'] = $refresh->getId();
     }
     $parameters = $this->getDisplay('parameters');
     if (is_array($parameters)) {
         foreach ($parameters as $key => $value) {
             $replace['#' . $key . '#'] = $value;
         }
     }
     if ($replace['#action#'] == '') {
         $html = template_replace($replace, getTemplate('core', $_version, 'networks', 'networks'));
     } else {
         $html = template_replace($replace, getTemplate('core', $_version, 'networks2', 'networks'));
     }
     cache::set('networksWidget' . $_version . $this->getId(), $html, 0);
     return $html;
 }
开发者ID:eliovir,项目名称:plugin-networks,代码行数:54,代码来源:networks.class.php

示例15: invalidCache

 public function invalidCache()
 {
     $mc = cache::byKey('cmd' . $this->getId());
     $mc->invalid();
 }
开发者ID:jimibi,项目名称:core,代码行数:5,代码来源:cmd.class.php


注:本文中的cache::byKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。