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


PHP config::byKey方法代码示例

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


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

示例1: baseUrl

 private static function baseUrl()
 {
     if (config::byKey('nodeJsKey') == '') {
         self::updateKey();
     }
     return '127.0.0.1:' . config::byKey('nodeJsInternalPort') . '?key=' . config::byKey('nodeJsKey') . '&';
 }
开发者ID:GaelGRIFFON,项目名称:core,代码行数:7,代码来源:nodejs.class.php

示例2: runDeamon

 public static function runDeamon()
 {
     if (!file_exists('/opt/homebridge/config.json')) {
         $response = array();
         $platform = array();
         $response['description'] = "Configuration Jeedom";
         $platform['platform'] = "Jeedom";
         $platform['name'] = "Jeedom";
         $platform['jeedom_ip'] = "127.0.0.1";
         $platform['jeedom_port'] = config::byKey('internalPort');
         $platform['jeedom_url'] = config::byKey('internalComplement');
         $platform['jeedom_api_key'] = config::byKey('api');
         $response['platforms'] = array();
         $response['platforms'][] = $platform;
         $response['accessories'] = array();
         $fp = fopen('/opt/homebridge/config.json', 'w');
         fwrite($fp, json_encode($response));
         fclose($fp);
     }
     log::add('homebridge', 'info', 'Lancement du démon homebridge');
     $cmd = 'nice -n 19 /usr/bin/nodejs /opt/homebridge/app.js';
     log::add('homebridge', 'info', 'Lancement démon homebridge : ' . $cmd);
     $result = exec('nohup ' . $cmd . ' >> ' . log::getPathToLog('homebridge') . ' 2>&1 &');
     if (!self::deamonRunning()) {
         sleep(10);
         if (!self::deamonRunning()) {
             log::add('homebridge', 'error', 'Impossible de lancer le démon homebridge', 'unableStartDeamon');
             return false;
         }
     }
     message::removeAll('homebridge', 'unableStartDeamon');
     log::add('homebridge', 'info', 'Démon homebridge lancé');
 }
开发者ID:julien30,项目名称:plugin-homebridge,代码行数:33,代码来源:homebridge.class.php

示例3: openzwave_update

function openzwave_update()
{
    if (openzwave::deamonRunning()) {
        echo 'Stop zwave network...';
        openzwave::stopDeamon();
        echo "OK\n";
    }
    echo 'Stop cron...';
    $cron = cron::byClassAndFunction('openzwave', 'pull');
    if (config::byKey('jeeNetwork::mode') != 'slave') {
        if (!is_object($cron)) {
            $cron = new cron();
        }
        $cron->setClass('openzwave');
        $cron->setFunction('pull');
        $cron->setEnable(1);
        $cron->setDeamon(1);
        $cron->setDeamonSleepTime(0.5);
        $cron->setTimeout(1440);
        $cron->setSchedule('* * * * *');
        $cron->save();
        $cron->stop();
    } else {
        if (is_object($cron)) {
            $cron->remove();
        }
    }
    echo "OK\n";
    echo 'Check zwave system...';
    if (count(eqLogic::byType('zwave')) > 0) {
        log::add('openzwave', 'error', 'Attention vous etes sur la nouvelle version d\'openzwave, des actions de votre part sont necessaire merci d\'aller voir https://jeedom.fr/blog/?p=1576');
    }
    if (config::byKey('port', 'openzwave', 'none') != 'none') {
        if (method_exists('openzwave', 'getVersion')) {
            if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) {
                if (jeedom::getHardwareName() == 'Jeedomboard') {
                    config::save('allowStartDeamon', 0, 'openzwave');
                    openzwave::updateOpenzwave(false);
                    config::save('allowStartDeamon', 1, 'openzwave');
                } else {
                    log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur le démon local, il faut ABSOLUMENT la mettre à jour', __FILE__));
                }
            }
        }
    }
    if (config::byKey('jeeNetwork::mode') == 'master') {
        foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) {
            try {
                if ($jeeNetwork->configByKey('port', 'openzwave', 'none') != 'none') {
                    if (version_compare($jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')), openzwave::getVersion('openzwave'), '>')) {
                        log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur', __FILE__) . ' ' . $jeeNetwork->getName() . ' ' . __('il faut ABSOLUMENT la mettre à jour', __FILE__));
                    }
                }
            } catch (Exception $e) {
            }
        }
    }
    echo "OK\n";
}
开发者ID:stef3569,项目名称:plugin-openzwave,代码行数:59,代码来源:install.php

示例4: remove

function remove()
{
    $cron = cron::byId(config::byKey('xPLDeamonCronId', 'xPL'));
    if (is_object($cron)) {
        $cron->remove();
    }
    config::remove('xPLDeamonCronId', 'xPL');
}
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:8,代码来源:install.php

示例5: openzwave_update

function openzwave_update()
{
    log::add('openzwave', 'error', __('Après toute installation/mise à jour pensez bien à mettre à jour les dépendances Openzwave (voir documentation)', __FILE__));
    if (!file_exists(dirname(__FILE__) . '/../data')) {
        mkdir(dirname(__FILE__) . '/../data');
    }
    shell_exec('cp -R /opt/python-openzwave/xml_backups ' . dirname(__FILE__) . '/../data');
    shell_exec('cp -R /opt/python-openzwave/zwcfg_*.xml ' . dirname(__FILE__) . '/../data');
    shell_exec('rm -rf /opt/python-openzwave/xml_backups');
    shell_exec('rm -rf /opt/python-openzwave/zwcfg_*.xml');
    config::save('allowStartDeamon', 0, 'openzwave');
    echo 'Stop zwave network...';
    openzwave::stop();
    openzwave::stopDeamon();
    echo "OK\n";
    echo 'Stop cron...';
    $cron = cron::byClassAndFunction('openzwave', 'pull');
    if (is_object($cron)) {
        $cron->remove();
    }
    echo "OK\n";
    echo 'Check zwave system...';
    if (count(eqLogic::byType('zwave')) > 0) {
        log::add('openzwave', 'error', 'Attention vous etes sur la nouvelle version d\'openzwave, des actions de votre part sont necessaire merci d\'aller voir https://jeedom.fr/blog/?p=1576');
    }
    if (config::byKey('port', 'openzwave', 'none') != 'none') {
        if (method_exists('openzwave', 'getVersion')) {
            if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) {
                if (jeedom::getHardwareName() == 'Jeedomboard') {
                    openzwave::updateOpenzwave(false);
                } else {
                    log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur le démon local, il faut ABSOLUMENT la mettre à jour', __FILE__));
                }
            }
        }
    }
    if (config::byKey('jeeNetwork::mode') == 'master') {
        foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) {
            try {
                if ($jeeNetwork->configByKey('port', 'openzwave', 'none') != 'none') {
                    if (version_compare($jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')), openzwave::getVersion('openzwave'), '>')) {
                        log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur', __FILE__) . ' ' . $jeeNetwork->getName() . ' ' . __('il faut ABSOLUMENT la mettre à jour', __FILE__));
                    }
                }
            } catch (Exception $e) {
            }
        }
    }
    echo "OK\n";
    echo 'Redemarrage zwave network...';
    try {
        config::save('allowStartDeamon', 1, 'openzwave');
        openzwave::runDeamon();
    } catch (Exception $e) {
    }
    echo "OK\n";
}
开发者ID:kaneda-fr,项目名称:plugin-openzwave,代码行数:57,代码来源:install.php

示例6: execute

 public function execute($_options = null)
 {
     $request = str_replace('#API#', config::byKey('api'), $this->getConfiguration('request'));
     if ($_options != null) {
         switch ($this->getType()) {
             case 'action':
                 switch ($this->getSubType()) {
                     case 'slider':
                         $request = str_replace('#slider#', $_options['slider'], $request);
                         break;
                     case 'color':
                         $request = str_replace('#color#', $_options['color'], $request);
                         break;
                     case 'message':
                         $replace = array('#title#', '#message#');
                         $replaceBy = array($_options['title'], $_options['message']);
                         if ($_options['message'] == '' || $_options['title'] == '') {
                             throw new Exception('[Script] Le message et le sujet ne peuvent être vide');
                         }
                         $request = str_replace($replace, $replaceBy, $request);
                         break;
                 }
                 break;
         }
     }
     switch ($this->getConfiguration('requestType')) {
         case 'http':
             $request_http = new com_http($request);
             log::add('script', 'info', 'Execution http de "' . $request . '"');
             return $request_http->exec();
             break;
         case 'script':
             $pathinfo = pathinfo($request);
             switch ($pathinfo['extension']) {
                 case 'php':
                     $request_shell = new com_shell('php ' . $request);
                     break;
                 case 'rb':
                     $request_shell = new com_shell('ruby ' . $request);
                     break;
                 case 'py':
                     $request_shell = new com_shell('python ' . $request);
                     break;
                 case 'pl':
                     $request_shell = new com_shell('perl ' . $request);
                     break;
                 default:
                     $request_shell = new com_shell($request);
                     break;
             }
             log::add('script', 'info', 'Execution shell de "' . $request . '"');
             return $request_shell->exec();
             break;
     }
     return false;
 }
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:56,代码来源:script.class.php

示例7: updateporkfolio

 public static function updateporkfolio()
 {
     log::remove('porkfolio_update');
     $clientid = config::byKey('clientid', 'porkfolio', 0);
     $clientsecret = config::byKey('clientsecret', 'porkfolio', 0);
     $username = config::byKey('username', 'porkfolio', 0);
     $password = config::byKey('password', 'porkfolio', 0);
     $cmd = '/usr/bin/python ' . dirname(__FILE__) . '/../../3rdparty/py-wink-adapt/login.py ' . $clientid . ' ' . $clientsecret . ' ' . $username . ' ' . $password;
     $cmd .= ' >> ' . log::getPathToLog('porkfolio_update') . ' 2>&1 &';
     exec($cmd);
 }
开发者ID:jeedom,项目名称:plugin-porkfolio,代码行数:11,代码来源:porkfolio.class.php

示例8: zwave_update

function zwave_update()
{
    $cron = cron::byClassAndFunction('zwave', 'pull');
    if (config::byKey('jeeNetwork::mode') != 'slave') {
        if (!is_object($cron)) {
            $cron = new cron();
        }
        $cron->setClass('zwave');
        $cron->setFunction('pull');
        $cron->setEnable(1);
        $cron->setDeamon(1);
        $cron->setTimeout(1440);
        $cron->setSchedule('* * * * *');
        $cron->save();
        $cron->stop();
    } else {
        if (is_object($cron)) {
            $cron->remove();
        }
    }
    foreach (zwave::byType('zwave') as $zwave) {
        if ($zwave->getConfiguration('serverID') == '') {
            $zwave->setConfiguration('serverID', 1);
        }
        $zwave->save();
    }
    config::save('zwaveAddr1', config::byKey('zwaveAddr1', 'zwave', config::byKey('zwaveAddr', 'zwave')), 'zwave');
    config::save('zwavePort1', config::byKey('zwavePort1', 'zwave', config::byKey('zwavePort', 'zwave')), 'zwave');
    config::save('isOpenZwave1', config::byKey('isOpenZwave1', 'zwave', config::byKey('isOpenZwave', 'zwave')), 'zwave');
    if (method_exists('zwave', 'listServerZway')) {
        foreach (zwave::listServerZway() as $serverID => $server) {
            if (config::byKey('lastNotificationCheck' . $serverID, 'zwave', 0) == 0) {
                config::save('lastNotificationCheck' . $serverID, strtotime('now'), 'zwave');
            }
        }
    }
}
开发者ID:ksoul78,项目名称:plugin-zwave,代码行数:37,代码来源:install.php

示例9: arduidom_update

function arduidom_update()
{
    arduidom::stopdaemon();
    $MigrationCheck = config::byKey('db_version', 'arduidom', 0);
    if ($MigrationCheck < 108) {
        arduidom::MigrateDatas();
        arduidom::start();
    }
    if ($MigrationCheck < 145) {
        arduidom::stopdaemon();
        $daemon_path = realpath(dirname(__FILE__) . '/../../ressources');
        log::add('arduidom', 'info', "Suppression de arduidom1.py devenu inutile => " . unlink($daemon_path . "/arduidom1.py"));
        log::add('arduidom', 'info', "Suppression de arduidom2.py devenu inutile => " . unlink($daemon_path . "/arduidom2.py"));
        log::add('arduidom', 'info', "Suppression de arduidom3.py devenu inutile => " . unlink($daemon_path . "/arduidom3.py"));
        log::add('arduidom', 'info', "Suppression de arduidom4.py devenu inutile => " . unlink($daemon_path . "/arduidom4.py"));
        log::add('arduidom', 'info', "Suppression de arduidom5.py devenu inutile => " . unlink($daemon_path . "/arduidom5.py"));
        log::add('arduidom', 'info', "Suppression de arduidom6.py devenu inutile => " . unlink($daemon_path . "/arduidom6.py"));
        log::add('arduidom', 'info', "Suppression de arduidom7.py devenu inutile => " . unlink($daemon_path . "/arduidom7.py"));
        log::add('arduidom', 'info', "Suppression de arduidom8.py devenu inutile => " . unlink($daemon_path . "/arduidom8.py"));
        config::save('db_version', 145, 'arduidom');
        // Inscrit la version de migration dans la config
        arduidom::start();
    }
    arduidom::startdaemon();
    $cron = cron::byClassAndFunction('arduidom', 'checkdaemon');
    if (!is_object($cron)) {
        $cron = new cron();
        $cron->setClass('arduidom');
        $cron->setFunction('checkdaemon');
        $cron->setEnable(1);
        $cron->setDeamon(0);
        $cron->setSchedule('* * * * *');
        $cron->save();
    }
    $cron->stop();
    @exec("sudo usermod -G dialout www-data");
}
开发者ID:cedric222,项目名称:arduidom,代码行数:37,代码来源:install.php

示例10: getHardwareName

 public static function getHardwareName()
 {
     if (config::byKey('hardware_name') != '') {
         return config::byKey('hardware_name');
     }
     $result = 'DIY';
     $uname = shell_exec('uname -a');
     if (strpos($uname, 'cubox') !== false) {
         $result = 'Jeedomboard';
     } else {
         if (file_exists('/.dockerinit')) {
             $result = 'Docker';
         } else {
             if (file_exists('/usr/bin/raspi-config')) {
                 $result = 'RPI/RPI2';
             }
         }
     }
     config::save('hardware_name', $result);
     return config::byKey('hardware_name');
 }
开发者ID:GaelGRIFFON,项目名称:core,代码行数:21,代码来源:jeedom.class.php

示例11: Exception

<?php

if (!isConnect('admin')) {
    throw new Exception('Error 401 Unauthorized');
}
sendVarToJS('eqType', 'bluetooth');
$secure = 0;
$options = array();
$port = config::byKey('port', 'bluetooth');
echo '<div class="row row-overflow">

    <div class="col-lg-12 eqLogic" style="border-left: solid 1px #EEE; padding-left: 25px;">
        <div class="row">
            <div class="col-lg-12">
               <legend>{{équipements Bluetooth à proximité}}</legend> 
            </div>
        </div>
        <button onclick="printDiscoverBT()">{{Rafraichir}}</button><br><br>
        <table id="table_discover_bt" class="table table-bordered table-condensed">
            <thead>
                <tr>
                    <th>{{MAC}}</th>
                    <th>{{Nom}}</th>
                    <th>{{Type}}</th>
                    <th>{{Services}}</th>
                    <th>{{Action}}</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
开发者ID:jeedom,项目名称:plugin-bluetooth,代码行数:31,代码来源:bluetooth.php

示例12: executeAndReply

 public function executeAndReply($_parameters)
 {
     $interactDef = interactDef::byId($this->getInteractDef_id());
     if (!is_object($interactDef)) {
         return __('Inconsistance de la base de données', __FILE__);
     }
     if (isset($_parameters['profile']) && trim($interactDef->getPerson()) != '') {
         $person = strtolower($interactDef->getPerson());
         $person = explode('|', $person);
         if (!in_array($_parameters['profile'], $person)) {
             return __('Vous n\'êtes pas autorisé à exécuter cette action', __FILE__);
         }
     }
     $reply = $interactDef->selectReply();
     $replace = array();
     $tags = interactDef::getTagFromQuery($this->getQuery(), $_parameters['dictation']);
     $tags_replace = array();
     foreach ($tags as $key => $value) {
         $tags_replace['#' . $key . '#'] = $value;
         $replace['#' . $key . '#'] = $value;
     }
     $executeDate = null;
     $dateConvert = array('heure' => 'hour', 'mois' => 'month', 'semaine' => 'week', 'année' => 'year');
     if (isset($tags_replace['#duration#'])) {
         $tags_replace['#duration#'] = str_replace(array_keys($dateConvert), $dateConvert, $tags_replace['#duration#']);
         $executeDate = strtotime('+' . $tags_replace['#duration#']);
     }
     if (isset($tags_replace['#time#'])) {
         $time = str_replace(array('h'), array(':'), $tags_replace['#time#']);
         if (strlen($time) == 2) {
             $time .= ':00';
         } else {
             if (strlen($time) == 3) {
                 $time .= '00';
             }
         }
         $executeDate = strtotime($time);
         if ($executeDate < strtotime('now')) {
             $executeDate += 3600;
         }
     }
     if ($executeDate !== null && !isset($_parameters['execNow'])) {
         if (date('Y', $executeDate) < 2000) {
             return __('Erreur impossible de calculer la date de programmation', __FILE__);
         }
         if ($executeDate < strtotime('now') + 60) {
             $executeDate = strtotime('now') + 60;
         }
         $crons = cron::searchClassAndFunction('interactQuery', 'doIn', '"interactQuery_id":' . $this->getId());
         if (is_array($crons)) {
             foreach ($crons as $cron) {
                 if ($cron->getState() != 'run') {
                     $cron->remove();
                 }
             }
         }
         $cron = new cron();
         $cron->setClass('interactQuery');
         $cron->setFunction('doIn');
         $cron->setOption(array_merge(array('interactQuery_id' => intval($this->getId())), $_parameters));
         $cron->setLastRun(date('Y-m-d H:i:s'));
         $cron->setOnce(1);
         $cron->setSchedule(date('i', $executeDate) . ' ' . date('H', $executeDate) . ' ' . date('d', $executeDate) . ' ' . date('m', $executeDate) . ' * ' . date('Y', $executeDate));
         $cron->save();
         $replace['#value#'] = date('Y-m-d H:i:s', $executeDate);
         $result = scenarioExpression::setTags(str_replace(array_keys($replace), $replace, $reply));
         return $result;
     }
     $colors = config::byKey('convertColor');
     foreach ($this->getActions('cmd') as $action) {
         try {
             $options = array();
             if (isset($action['options'])) {
                 $options = $action['options'];
             }
             if ($tags != null) {
                 foreach ($options as &$option) {
                     $option = str_replace(array_keys($tags_replace), $tags_replace, $option);
                 }
                 if (isset($options['color']) && isset($colors[strtolower($options['color'])])) {
                     $options['color'] = $colors[strtolower($options['color'])];
                 }
             }
             $cmd = cmd::byId(str_replace('#', '', $action['cmd']));
             if (is_object($cmd) && $cmd->getType() == 'info') {
                 $replace['#unite#'] = $cmd->getUnite();
                 $replace['#commande#'] = $cmd->getName();
                 $replace['#objet#'] = '';
                 $replace['#equipement#'] = '';
                 $eqLogic = $cmd->getEqLogic();
                 if (is_object($eqLogic)) {
                     $replace['#equipement#'] = $eqLogic->getName();
                     $object = $eqLogic->getObject();
                     if (is_object($object)) {
                         $replace['#objet#'] = $object->getName();
                     }
                 }
             }
             $options['tags'] = $tags_replace;
             $return = scenarioExpression::createAndExec('action', $action['cmd'], $options);
//.........这里部分代码省略.........
开发者ID:saez0pub,项目名称:core,代码行数:101,代码来源:interactQuery.class.php

示例13: setIsEnable

 public function setIsEnable($_state)
 {
     if (version_compare(jeedom::version(), $this->getRequire()) == -1 && $_state == 1) {
         throw new Exception('Votre version de jeedom n\'est pas assez récente pour activer ce plugin');
     }
     $alreadyActive = config::byKey('active', $this->getId(), 0);
     if ($_state == 1) {
         if (config::byKey('jeeNetwork::mode') != 'master' && $this->getAllowRemote() != 1) {
             throw new Exception('Vous ne pouvez pas activer ce plugin sur un Jeedom configuré en esclave');
         }
         //market::checkPayment($this->getId());
         config::save('active', $_state, $this->getId());
     }
     if ($_state == 0) {
         $eqLogics = eqLogic::byType($this->getId());
         if (is_array($eqLogics)) {
             foreach ($eqLogics as $eqLogic) {
                 try {
                     $eqLogic->setConfiguration('previousIsEnable', $eqLogic->getIsEnable());
                     $eqLogic->setConfiguration('previousIsVisible', $eqLogic->getIsVisible());
                     $eqLogic->setIsEnable(0);
                     $eqLogic->setIsVisible(0);
                     $eqLogic->save();
                 } catch (Exception $e) {
                 }
             }
         }
         $listeners = listener::byClass($this->getId());
         if (is_array($listeners)) {
             foreach ($listeners as $listener) {
                 $listener->remove();
             }
         }
     }
     if ($alreadyActive == 0 && $_state == 1) {
         foreach (eqLogic::byType($this->getId()) as $eqLogic) {
             try {
                 $eqLogic->setIsEnable($eqLogic->getConfiguration('previousIsEnable', 1));
                 $eqLogic->setIsVisible($eqLogic->getConfiguration('previousIsVisible', 1));
                 $eqLogic->save();
             } catch (Exception $e) {
             }
         }
     }
     try {
         if ($_state == 1) {
             if ($alreadyActive == 1) {
                 $out = $this->callInstallFunction('update');
             } else {
                 $out = $this->callInstallFunction('install');
             }
         } else {
             if ($alreadyActive == 1) {
                 $out = $this->callInstallFunction('remove');
             }
         }
         if (isset($out) && trim($out) != '') {
             log::add($this->getId(), 'info', "Installation/remove/update result : " . $out);
         }
     } catch (Exception $e) {
         config::save('active', $alreadyActive, $this->getId());
         log::add('plugin', 'error', $e->getMessage());
         throw $e;
     }
     if ($_state == 0) {
         config::save('active', $_state, $this->getId());
     }
     return true;
 }
开发者ID:saez0pub,项目名称:core,代码行数:69,代码来源:plugin.class.php

示例14: connectToLDAP

 public static function connectToLDAP()
 {
     $ad = ldap_connect(config::byKey('ldap:host'), config::byKey('ldap:port'));
     ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
     ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
     if (ldap_bind($ad, config::byKey('ldap:username'), config::byKey('ldap:password'))) {
         return $ad;
     }
     return false;
 }
开发者ID:GaelGRIFFON,项目名称:core,代码行数:10,代码来源:user.class.php

示例15: save

 public function save()
 {
     if (trim($this->getName()) == '') {
         throw new Exception(__('Le nom du widget ne peut etre vide', __FILE__));
     }
     $allowWritePath = config::byKey('allowWriteDir', 'widget');
     if (!hadFileRight($allowWritePath, $this->generatePath())) {
         throw new Exception(__('Vous n\'etes pas autoriser à écrire : ', __FILE__) . $this->generatePath());
     }
     file_put_contents($this->generatePath(), $this->getContent());
     if (realpath($this->getPath()) != realpath($this->generatePath())) {
         if (file_exists($this->getPath())) {
             unlink($this->getPath());
             $informations = explode('.', $this->getPath());
             $name = $informations[count($informations) - 2];
             $type = $informations[count($informations) - 4];
             $subtype = $informations[count($informations) - 3];
             $cmds = cmd::searchTemplate('"' . $this->getVersion() . '":"' . $name . '"', null, $type, $subtype);
             foreach ($cmds as $cmd) {
                 $cmd->setTemplate($this->getVersion(), $this->getName());
                 $cmd->save();
             }
         }
         if (is_dir(str_replace('.html', '', $this->getPath()))) {
             if (!rename(str_replace('.html', '', $this->getPath()), str_replace('.html', '', $this->generatePath()))) {
                 throw new Exception(__('Impossible de déplacer : ', __FILE__) . str_replace('.html', '', $this->getPath()) . __(' vers ', __FILE__) . str_replace('.html', '', $this->generatePath()));
             }
         }
     }
     foreach ($this->getUsedBy() as $cmd) {
         $cmd->save();
     }
     return true;
 }
开发者ID:tlo,项目名称:plugin-widget,代码行数:34,代码来源:widget.class.php


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