Пример #1
0
 /**
  * Transform Pagination.
  *
  * @return array
  */
 private function transformPaginator()
 {
     $results = array_map(function ($object) {
         return $this->transformation($object, false);
     }, $this->object->all());
     return array_merge(['data' => $results], $this->getPaginationMeta());
 }
 protected function getSubscriptions($userId)
 {
     // if user explicitly passed, we will return that only
     if (!is_null($userId)) {
         return [$this->subscriptionRepo->subscription($userId)];
     }
     return $this->subscriptionRepo->all();
 }
Пример #3
0
 /**
  * Description
  * @param object $request
  * @param string $destino
  * @return array
  */
 public function cropImage($request, $destino)
 {
     $data = $request->all();
     if ($request->hasFile('avatar')) {
         $novoNome = date('d-m-Y-h-i-s') . '-' . $request->file('avatar')->getClientOriginalName();
         if ($data['x1'] !== '' && $data['x2'] !== '' && $data['y1'] !== '' && $data['y2'] !== '') {
             $w = $data['x2'] - $data['x1'];
             $h = $data['y2'] - $data['y1'];
             $x = $data['x1'];
             $y = $data['y1'];
             Image::configure(array('driver' => 'gd'));
             $image = Image::make($request->file('avatar'));
             // width, height, $x, $y
             $image->crop($w, $h, $x, $y);
             $image->save($destino . $novoNome);
         } else {
             $image = Image::make($request->file('avatar'));
             $image->save($destino . $novoNome);
         }
         $data["avatar"] = $novoNome;
     }
     unset($data['_token']);
     unset($data['x1']);
     unset($data['y1']);
     unset($data['x2']);
     unset($data['y2']);
     return $data;
 }
 /**
  * Add bulk actions
  *
  * @return array
  **/
 public function bulk_actions_categories()
 {
     $output = '<select name="plugin_category_select" id="bulk-action-selector-category" style="display:none">';
     foreach ((array) $this->category->all() as $category) {
         $output .= '<option value="' . $category->id . '">' . $category->name . '</option>';
     }
     $output .= '</select>';
     echo $output;
 }
Пример #5
0
 /**
  * @return array
  */
 private function getAllFromDatabase()
 {
     if ($this->config->get('use_database')) {
         $database_ips = $this->model->all();
         return $database_ips;
     } else {
         $database_ips = $this->toCollection(array());
         return $database_ips;
     }
 }
Пример #6
0
 /**
  * Clears the session
  *
  * Either clears the entire session, or by prefix
  */
 protected function clear()
 {
     if ($this->prefix) {
         foreach ($this->session->all() as $s => $v) {
             if (strpos($s, $this->prefix) === 0) {
                 $this->remove($s);
             }
         }
     } else {
         $this->session->clear();
     }
 }
 /**
  * Get an array of collection values.
  *
  * @param  object  $value
  * @return array
  */
 protected function getArrayObjectValue($value)
 {
     return $value->all();
 }
Пример #8
0
<?php

if (!hasRight('displayview', true)) {
    throw new Exception('{{401 - Accès non autorisé}}');
}
$nbEqlogic = 0;
$nbCmd = 0;
$objects = object::all();
$eqLogics = array();
$cmds = array();
$eqLogics[-1] = eqLogic::byObjectId(null, false);
foreach ($eqLogics[-1] as $eqLogic) {
    $cmds[$eqLogic->getId()] = $eqLogic->getCmd();
    $nbCmd += count($cmds[$eqLogic->getId()]);
}
$nbEqlogic += count($eqLogics[-1]);
foreach ($objects as $object) {
    $eqLogics[$object->getId()] = $object->getEqLogic(false, false);
    foreach ($eqLogics[$object->getId()] as $eqLogic) {
        $cmds[$eqLogic->getId()] = $eqLogic->getCmd();
        $nbCmd += count($cmds[$eqLogic->getId()]);
    }
    $nbEqlogic += count($eqLogics[$object->getId()]);
}
?>
<style>
	.eqLogicSortable{
		list-style-type: none;
		min-height: 20px;
		padding-left: 0px;
	}
Пример #9
0
 public function all()
 {
     return $this->model->all();
 }
Пример #10
0
 public static function changeMode($_mode)
 {
     switch ($_mode) {
         case 'master':
             if (config::byKey('jeeNetwork::mode') != 'master') {
                 $cron = new cron();
                 $cron->setClass('history');
                 $cron->setFunction('historize');
                 $cron->setSchedule('*/5 * * * * *');
                 $cron->setTimeout(5);
                 $cron->save();
                 $cron = new cron();
                 $cron->setClass('scenario');
                 $cron->setFunction('check');
                 $cron->setSchedule('* * * * * *');
                 $cron->setTimeout(5);
                 $cron->save();
                 $cron = new cron();
                 $cron->setClass('cmd');
                 $cron->setFunction('collect');
                 $cron->setSchedule('*/5 * * * * *');
                 $cron->setTimeout(5);
                 $cron->save();
                 $cron = new cron();
                 $cron->setClass('history');
                 $cron->setFunction('archive');
                 $cron->setSchedule('00 * * * * *');
                 $cron->setTimeout(20);
                 $cron->save();
                 config::save('jeeNetwork::mode', 'master');
             }
             break;
         case 'slave':
             if (config::byKey('jeeNetwork::mode') != 'slave') {
                 foreach (eqLogic::all() as $eqLogic) {
                     $eqLogic->remove();
                 }
                 foreach (object::all() as $object) {
                     $object->remove();
                 }
                 foreach (update::all() as $update) {
                     switch ($update->getType()) {
                         case 'core':
                             break;
                         case 'plugin':
                             try {
                                 $plugin = plugin::byId($update->getLogicalId());
                                 if (is_object($plugin) && $plugin->getAllowRemote() != 1) {
                                     $update->deleteObjet();
                                 }
                             } catch (Exception $e) {
                             }
                             break;
                         default:
                             $update->deleteObjet();
                             break;
                     }
                 }
                 foreach (view::all() as $view) {
                     $view->remove();
                 }
                 foreach (plan::all() as $plan) {
                     $plan->remove();
                 }
                 foreach (scenario::all() as $scenario) {
                     $scenario->remove();
                 }
                 foreach (listener::all() as $listener) {
                     $listener->remove();
                 }
                 $cron = cron::byClassAndFunction('history', 'historize');
                 if (is_object($cron)) {
                     $cron->remove();
                 }
                 $cron = cron::byClassAndFunction('scenario', 'check');
                 if (is_object($cron)) {
                     $cron->remove();
                 }
                 $cron = cron::byClassAndFunction('cmd', 'collect');
                 if (is_object($cron)) {
                     $cron->remove();
                 }
                 $cron = cron::byClassAndFunction('history', 'archive');
                 if (is_object($cron)) {
                     $cron->remove();
                 }
                 $user = new user();
                 $user->setLogin('jeedom_master');
                 $user->setPassword(config::genKey(255));
                 $user->setRights('admin', 1);
                 $user->save();
                 config::save('jeeNetwork::mode', 'slave');
             }
             break;
     }
 }
Пример #11
0
 /**
  * Calls the model controller's all method to returns all records in a table,
  * defaulting the modeled table name.
  *
  * @param string $orderby Fields for the ORDER BY clause.
  * @param int $count Number of records to return.  null = all
  * @param int $start Index of first record to return.  null = 0
  * @param string $indexby (NOT YET IMPLEMENTED)
  * @return object An handler instance of result_class for query results.
  */
 public function all($orderby = null, $count = null, $start = null, $indexby = null)
 {
     return $this->model->all($this->table_name, $orderby, $count, $start, $indexby);
 }
Пример #12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $input = $this->request->all();
     $experiences = $this->products->fetchAll('mobile', ['events, experiences'], $input);
     return response()->json($experiences['data'], $experiences['code']);
 }
Пример #13
0
 /**
  * All - gets all the values from the param bag
  *
  * @return array
  * @author Dan Cox
  */
 public static function all()
 {
     return static::$parameterBag->all();
 }
Пример #14
0
 public static function fullData($_restrict = array())
 {
     $return = array();
     foreach (object::all(true) as $object) {
         if (!is_array($_restrict['object']) || isset($_restrict['object'][$object->getId()])) {
             $object_return = utils::o2a($object);
             $object_return['eqLogics'] = array();
             foreach ($object->getEqLogic(true, true) as $eqLogic) {
                 if (!isset($_restrict['eqLogic']) || !is_array($_restrict['eqLogic']) || isset($_restrict['eqLogic'][$eqLogic->getId()])) {
                     $eqLogic_return = utils::o2a($eqLogic);
                     $eqLogic_return['cmds'] = array();
                     foreach ($eqLogic->getCmd() as $cmd) {
                         if (!isset($_restrict['cmd']) || !is_array($_restrict['cmd']) || isset($_restrict['cmd'][$cmd->getId()])) {
                             $cmd_return = utils::o2a($cmd);
                             if ($cmd->getType() == 'info') {
                                 $cmd_return['state'] = $cmd->execCmd(null, 2);
                             }
                             $eqLogic_return['cmds'][] = $cmd_return;
                         }
                     }
                     $object_return['eqLogics'][] = $eqLogic_return;
                 }
             }
             $return[] = $object_return;
         }
     }
     cache::set('api::object::full', json_encode($return), 0);
     return $return;
 }
Пример #15
0
 public static function whatDoYouKnow($_object = null)
 {
     $result = array();
     if (is_object($_object)) {
         $objects = array($_object);
     } else {
         $objects = object::all();
     }
     foreach ($objects as $object) {
         foreach ($object->getEqLogic() as $eqLogic) {
             if ($eqLogic->getIsEnable() == 1) {
                 foreach ($eqLogic->getCmd() as $cmd) {
                     if ($cmd->getIsVisible() == 1 && $cmd->getType() == 'info') {
                         try {
                             $value = $cmd->execCmd();
                             if (!isset($result[$object->getId()])) {
                                 $result[$object->getId()] = array();
                                 $result[$object->getId()]['name'] = $object->getName();
                                 $result[$object->getId()]['eqLogic'] = array();
                             }
                             if (!isset($result[$object->getId()]['eqLogic'][$eqLogic->getId()])) {
                                 $result[$object->getId()]['eqLogic'][$eqLogic->getId()] = array();
                                 $result[$object->getId()]['eqLogic'][$eqLogic->getId()]['name'] = $eqLogic->getName();
                                 $result[$object->getId()]['eqLogic'][$eqLogic->getId()]['cmd'] = array();
                             }
                             $result[$object->getId()]['eqLogic'][$eqLogic->getId()]['cmd'][$cmd->getId()] = array();
                             $result[$object->getId()]['eqLogic'][$eqLogic->getId()]['cmd'][$cmd->getId()]['name'] = $cmd->getName();
                             $result[$object->getId()]['eqLogic'][$eqLogic->getId()]['cmd'][$cmd->getId()]['unite'] = $cmd->getUnite();
                             $result[$object->getId()]['eqLogic'][$eqLogic->getId()]['cmd'][$cmd->getId()]['value'] = $value;
                         } catch (Exception $exc) {
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
Пример #16
0
 public function generateQueryVariant()
 {
     $inputs = self::generateTextVariant($this->getQuery());
     $return = array();
     foreach ($inputs as $input) {
         preg_match_all("/#(.*?)#/", $input, $matches);
         $matches = $matches[1];
         if ($this->getLink_type() == 'cmd') {
             if (in_array('commande', $matches) && (in_array('objet', $matches) || in_array('equipement', $matches))) {
                 foreach (object::all() as $object) {
                     if ($this->getFiltres('object_id', 'all') == 'all' || $object->getId() == $this->getFiltres('object_id')) {
                         foreach ($object->getEqLogic() as $eqLogic) {
                             if ($this->getFiltres('eqLogic_id', 'all') == 'all' || $eqLogic->getId() == $this->getFiltres('eqLogic_id')) {
                                 if ($this->getFiltres('plugin', 'all') == 'all' || $eqLogic->getEqType_name() == $this->getFiltres('plugin')) {
                                     if ($this->getFiltres('eqLogic_category', 'all') == 'all' || $eqLogic->getCategory($this->getFiltres('eqLogic_category', 'all'), 0) == 1) {
                                         foreach ($eqLogic->getCmd() as $cmd) {
                                             if ($this->getFiltres('subtype') == 'all' || $this->getFiltres('subtype') == $cmd->getSubType()) {
                                                 if ($cmd->getType() == $this->getFiltres('cmd_type') && ($this->getFiltres('cmd_unite', 'all') == 'all' || $cmd->getUnite() == $this->getFiltres('cmd_unite'))) {
                                                     $replace = array('#objet#' => strtolower($object->getName()), '#commande#' => strtolower($cmd->getName()), '#equipement#' => strtolower($eqLogic->getName()));
                                                     $return[] = array('query' => str_replace(array_keys($replace), $replace, $input), 'link_type' => $this->getLink_type(), 'link_id' => $cmd->getId());
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($this->getLink_type() == 'whatDoYouKnow') {
             if (in_array('objet', $matches)) {
                 foreach (object::all() as $object) {
                     $replace = array('#objet#' => strtolower($object->getName()));
                     $return[] = array('query' => str_replace(array_keys($replace), $replace, $input), 'link_type' => $this->getLink_type(), 'link_id' => $object->getId());
                 }
             }
         }
     }
     if (count($return) == 0) {
         foreach ($inputs as $input) {
             $return[] = array('query' => $input, 'link_type' => $this->getLink_type(), 'link_id' => $this->getLink_id());
         }
     }
     if ($this->getOptions('synonymes') != '' && $this->getLink_type() == 'cmd') {
         $queries = $return;
         $synonymes = array();
         foreach (explode('|', $this->getOptions('synonymes')) as $value) {
             $values = explode('=', $value);
             $synonymes[strtolower($values[0])] = explode(',', $values[1]);
         }
         $return = array();
         foreach ($queries as $query) {
             foreach (self::generateSynonymeVariante($query['query'], $synonymes) as $synonyme) {
                 $query_info = $query;
                 $query_info['query'] = $synonyme;
                 $return[] = $query_info;
             }
         }
     }
     return $return;
 }
Пример #17
0
 if ($jsonrpc->getMethod() == 'ping') {
     $jsonrpc->makeSuccess('pong');
 }
 /*             * ***********************Version********************************* */
 if ($jsonrpc->getMethod() == 'version') {
     $jsonrpc->makeSuccess(jeedom::version());
 }
 /*             * ************************Plugin*************************** */
 if ($jsonrpc->getMethod() == 'plugin::listPlugin') {
     $activateOnly = isset($params['activateOnly']) && $params['activateOnly'] == 1 ? true : false;
     $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');
Пример #18
0
        <fieldset>
          <legend><i class="fa fa-arrow-circle-left eqLogicAction cursor" data-action="returnToThumbnailDisplay"></i> {{Général}} <i class='fa fa-cogs eqLogicAction pull-right cursor expertModeVisible' data-action='configure'></i></legend>
          <div class="form-group">
            <label class="col-sm-4 control-label">{{Nom de l'équipement}}</label>
            <div class="col-sm-6">
              <input type="text" class="eqLogicAttr form-control" data-l1key="id" style="display : none;" />
              <input type="text" class="eqLogicAttr form-control" data-l1key="name" placeholder="{{Nom de l'équipement}}"/>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-4 control-label" >{{Objet parent}}</label>
            <div class="col-sm-6">
              <select class="eqLogicAttr form-control" data-l1key="object_id">
                <option value="">{{Aucun}}</option>
                <?php 
foreach (object::all() as $object) {
    echo '<option value="' . $object->getId() . '">' . $object->getName() . '</option>';
}
?>
             </select>
           </div>
         </div>
         <div class="form-group">
          <label class="col-sm-4 control-label">{{Catégorie}}</label>
          <div class="col-sm-8">
            <?php 
foreach (jeedom::getConfiguration('eqLogic:category') as $key => $value) {
    echo '<label class="checkbox-inline">';
    echo '<input type="checkbox" class="eqLogicAttr" data-l1key="category" data-l2key="' . $key . '" />' . $value['name'];
    echo '</label>';
}
Пример #19
0
 /**
  * @return
  */
 public function all()
 {
     return $this->entity->all();
 }