From ba97c4154015b81f403f0adfadfc41960c96fdf0 Mon Sep 17 00:00:00 2001 From: Emmanuel Bernaszuk Date: Thu, 6 Feb 2025 17:07:32 +0100 Subject: [PATCH] core(cmd) : Improve cmd class PHPDoc --- core/class/cmd.class.php | 1075 +++++++++++++++++++++++++++++++++++--- 1 file changed, 1001 insertions(+), 74 deletions(-) diff --git a/core/class/cmd.class.php b/core/class/cmd.class.php index 0a7cc894bf..1326dea272 100644 --- a/core/class/cmd.class.php +++ b/core/class/cmd.class.php @@ -24,35 +24,87 @@ -> translate::exec($string, 'core/template/widgets.html'); */ +/** + * Jeedom command management class + * @see eqLogic + * @see jeeObject + */ class cmd { /* * *************************Attributs****************************** */ + /** @var int|''|null Command ID */ protected $id; + + /** @var int|null Logical identifier for the command */ protected $logicalId; + + /** @var string|null Generic type of command */ protected $generic_type; + + /** @var string|null Equipment type */ protected $eqType; + + /** @var string|null Command name */ protected $name; + + /** @var int|null Display order */ protected $order; + + /** @var string|null Command type ('action'|'info'|'string') */ protected $type; + + /** @var string|null Command subtype ('binary'|'numeric'|'message'|'color'|'slider'|'string') */ protected $subType; + + /** @var int|''|null ID of parent equipment */ protected $eqLogic_id; + + /** @var int Historization flag */ protected $isHistorized = 0; + + /** @var string Unit for values */ protected $unite = ''; + + /** @var string|null Command configuration */ protected $configuration; + + /** @var array Template configuration */ protected $template; + + /** @var array Display configuration */ protected $display; + + /** @var mixed|null Current value */ protected $value = null; + + /** @var int Visibility flag */ protected $isVisible = 1; + + /** @var array Alert configuration */ protected $alert; + + /** @var string Collect date */ protected $_collectDate = ''; + + /** @var string Value date */ protected $_valueDate = ''; - /** @var eqLogic */ + + /** @var eqLogic|null Parent equipment object */ protected $_eqLogic = null; + + /** @var bool Flag for widget refresh */ protected $_needRefreshWidget; + + /** @var bool Flag for alert refresh */ protected $_needRefreshAlert; - /** @var bool */ + + /** @var bool Change tracking flag */ protected $_changed = false; + + /** @var array Template array */ protected static $_templateArray = array(); + + /** @var array Unit conversion mapping */ protected static $_unite_conversion = array( 's' => array(60, 's', 'min', 'h'), 'W' => array(1000, 'W', 'kW', 'MW'), @@ -66,6 +118,13 @@ class cmd { ); /* * ***********************Méthodes statiques*************************** */ + /** + * Cast an object or array of objects to specific command type + * + * @param object|static[] $_inputs Objects to cast + * @param eqLogic|null $_eqLogic Parent equipment + * @return static|static[] Casted object(s) + */ private static function cast($_inputs, $_eqLogic = null) { if (is_object($_inputs) && class_exists($_inputs->getEqType() . 'Cmd')) { if ($_eqLogic !== null) { @@ -90,10 +149,12 @@ private static function cast($_inputs, $_eqLogic = null) { return $_inputs; } - /** - * @param int|string $_id the id of the command - * @return void|cmd void if $_id is not valid else the cmd - */ + /** + * Get a command by ID + * + * @param int|string $_id Command ID + * @return void|static Null if ID not valid, command object otherwise + */ public static function byId($_id) { if ($_id == '') { return; @@ -107,10 +168,12 @@ public static function byId($_id) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__)); } - /** - * @param array $_ids - * @return void|array void if $_ids is not valid else an array of cmd - */ + /** + * Get multiple commands by IDs + * + * @param array $_ids Array of command IDs + * @return void|static[] Null if IDs not valid, array of commands otherwise + */ public static function byIds($_ids) { if (!is_array($_ids) || count($_ids) == 0) { return; @@ -124,9 +187,11 @@ public static function byIds($_ids) { } } - /** - * @return array - */ + /** + * Get all commands + * + * @return static[] Array of all commands + */ public static function all() { $sql = 'SELECT ' . DB::buildField(__CLASS__) . ' FROM cmd @@ -134,6 +199,13 @@ public static function all() { return self::cast(DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get historized commands + * + * @param bool $_state Historization state to filter + * @return static[] Array of commands + * @throws Exception + */ public static function isHistorized($_state = true) { $values = array( 'isHistorized' => ($_state) ? 1 : 0 @@ -145,6 +217,12 @@ public static function isHistorized($_state = true) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get all history commands + * + * @return static[] Array of historical commands + * @throws Exception + */ public static function allHistoryCmd() { $sql = 'SELECT ' . DB::buildField(__CLASS__, 'c') . ' FROM cmd c @@ -165,16 +243,17 @@ public static function allHistoryCmd() { return array_merge($result1, $result2); } - /** - * - * @param int|array $_eqLogic_id - * @param string $_type ['action'|'info'] - * @param bool $_visible - * @param eqLogic $_eqLogic - * @param bool $_has_generic_type - * @return array - */ - public static function byEqLogicId($_eqLogic_id, $_type = null, $_visible = null, $_eqLogic = null, $_has_generic_type = null) { + /** + * Get commands by equipment ID + * + * @param int|int[] $_eqLogic_id Equipment ID(s) + * @param string|null $_type Command type ('action'|'info'|null) + * @param bool $_visible Filter on visible commands + * @param eqLogic $_eqLogic Parent equipment + * @param bool $_has_generic_type Filter on commands with generic type + * @return static[] Array of commands + */ + public static function byEqLogicId($_eqLogic_id, $_type = null, $_visible = null, $_eqLogic = null, $_has_generic_type = null) { $values = array(); if (is_array($_eqLogic_id)) { $sql = 'SELECT ' . DB::buildField(__CLASS__) . ' @@ -205,12 +284,13 @@ public static function byEqLogicId($_eqLogic_id, $_type = null, $_visible = null return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__), $_eqLogic); } - /** - * - * @param string $_logical_id - * @param string $_type ['action'|'info'] - * @return array - */ + /** + * Get commands by logical ID + * + * @param string $_logical_id Logical ID to search + * @param string|null $_type Command type ('action'|'info'|null) + * @return static[] Array of commands + */ public static function byLogicalId($_logical_id, $_type = null) { $values = array( 'logicalId' => $_logical_id, @@ -226,13 +306,14 @@ public static function byLogicalId($_logical_id, $_type = null) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } - /** - * - * @param string|array $_generic_type - * @param int $_eqLogic_id - * @param boolean $_one - * @return cmd|array first cmd if $_one is true otherwise an array of all cmd - */ + /** + * Get commands by generic type + * + * @param string|string[] $_generic_type Generic type(s) to search + * @param int|null $_eqLogic_id Equipment ID filter + * @param bool $_one Return only first result + * @return static|static[] First command if $_one is true otherwise array of commands + */ public static function byGenericType($_generic_type, $_eqLogic_id = null, $_one = false) { if (is_array($_generic_type)) { $in = ''; @@ -262,12 +343,13 @@ public static function byGenericType($_generic_type, $_eqLogic_id = null, $_one return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } - /** - * Search a command on eqType, logicalId, generic_type or name - * - * @param string $_search the needle - * @return array - */ + + /** + * Search commands by string + * + * @param string $_search Search string + * @return static[] Array of matching commands + */ public static function searchByString($_search) { $values = array( 'search' => '%' . $_search . '%' @@ -278,12 +360,13 @@ public static function searchByString($_search) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } - /** - * - * @param string|array $_configuration - * @param string $_eqType - * @return array - */ + /** + * Search commands by configuration + * + * @param string|string[] $_configuration Configuration to search + * @param string $_eqType Equipment type filter + * @return static[] Array of matching commands + */ public static function searchConfiguration($_configuration, $_eqType = null) { if (!is_array($_configuration)) { $values = array( @@ -315,6 +398,14 @@ public static function searchConfiguration($_configuration, $_eqType = null) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Search commands by display configuration + * + * @param array|string $_display Display configuration to search + * @param string|null $_eqType Equipment type filter + * @return static[] Array of matching commands + * @throws Exception + */ public static function searchDisplay($_display, $_eqType = null) { if (!is_array($_display)) { $values = array( @@ -343,6 +434,15 @@ public static function searchDisplay($_display, $_eqType = null) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Search commands by equipment configuration + * + * @param int $_eqLogic_id Equipment ID + * @param string $_configuration Configuration to search + * @param string|null $_type Command type filter ('action'|'info'|null) + * @return static[] Array of matching commands + * @throws Exception + */ public static function searchConfigurationEqLogic($_eqLogic_id, $_configuration, $_type = null) { $values = array( 'configuration' => '%' . $_configuration . '%', @@ -359,6 +459,16 @@ public static function searchConfigurationEqLogic($_eqLogic_id, $_configuration, return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Search commands by template + * + * @param string $_template Template to search + * @param string|null $_eqType Equipment type filter + * @param string|null $_type Command type filter ('action'|'info'|null) + * @param string|null $_subtype Command subtype filter + * @return static[] Array of matching commands + * @throws Exception + */ public static function searchTemplate($_template, $_eqType = null, $_type = null, $_subtype = null) { $values = array( 'template' => '%' . $_template . '%', @@ -382,6 +492,17 @@ public static function searchTemplate($_template, $_eqType = null, $_type = null return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get command by equipment ID and logical ID + * + * @param int $_eqLogic_id Equipment ID + * @param int $_logicalId Logical ID + * @param bool $_multiple Allow multiple results + * @param string|null $_type Command type filter ('action'|'info'|null) + * @param eqLogic|null $_eqLogic Parent equipment + * @return static|static[] Command(s) found + * @throws Exception + */ public static function byEqLogicIdAndLogicalId($_eqLogic_id, $_logicalId, $_multiple = false, $_type = null, $_eqLogic = null) { $values = array( 'eqLogic_id' => $_eqLogic_id, @@ -408,6 +529,17 @@ public static function byEqLogicIdAndLogicalId($_eqLogic_id, $_logicalId, $_mult return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get command by equipment ID and generic type + * + * @param int $_eqLogic_id Equipment ID + * @param string $_generic_type Generic type + * @param bool $_multiple Allow multiple results + * @param string|null $_type Command type filter ('action'|'info'|null) + * @param eqLogic|null $_eqLogic Parent equipment + * @return static|static[] Command(s) found + * @throws Exception + */ public static function byEqLogicIdAndGenericType($_eqLogic_id, $_generic_type, $_multiple = false, $_type = null, $_eqLogic = null) { $values = array( 'eqLogic_id' => $_eqLogic_id, @@ -433,6 +565,15 @@ public static function byEqLogicIdAndGenericType($_eqLogic_id, $_generic_type, $ return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get commands by generic type and object ID + * + * @param string $_generic_type Generic type + * @param int|null $_object_id Object ID filter + * @param string|null $_type Command type filter ('action'|'info'|null) + * @return static[]|void Array of commands or void if none found + * @throws Exception + */ public static function byGenericTypeObjectId($_generic_type, $_object_id = null, $_type = null) { $values = array( 'generic_type' => $_generic_type @@ -466,6 +607,15 @@ public static function byGenericTypeObjectId($_generic_type, $_object_id = null, return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get commands by value + * + * @param mixed $_value Value to search + * @param string|null $_type Command type filter ('action'|'info'|null) + * @param bool $_onlyEnable Filter on enabled equipment only + * @return static[] Array of matching commands + * @throws Exception + */ public static function byValue($_value, $_type = null, $_onlyEnable = false) { $values = array( 'value' => $_value, @@ -498,6 +648,15 @@ public static function byValue($_value, $_type = null, $_onlyEnable = false) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get command by equipment type, name and command name + * + * @param string $_eqType_name Equipment type + * @param string $_eqLogic_name Equipment name + * @param string $_cmd_name Command name + * @return static Matching command + * @throws Exception + */ public static function byTypeEqLogicNameCmdName($_eqType_name, $_eqLogic_name, $_cmd_name) { $values = array( 'eqType_name' => $_eqType_name, @@ -516,6 +675,14 @@ public static function byTypeEqLogicNameCmdName($_eqType_name, $_eqLogic_name, $ return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get command by equipment ID and command name + * + * @param int $_eqLogic_id Equipment ID + * @param string $_cmd_name Command name + * @return static Matching command + * @throws Exception + */ public static function byEqLogicIdCmdName($_eqLogic_id, $_cmd_name) { $values = array( 'eqLogic_id' => $_eqLogic_id, @@ -528,6 +695,15 @@ public static function byEqLogicIdCmdName($_eqLogic_id, $_cmd_name) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get command by object name, equipment name and command name + * + * @param string $_object_name Object name + * @param string $_eqLogic_name Equipment name + * @param string $_cmd_name Command name + * @return static Matching command + * @throws Exception + */ public static function byObjectNameEqLogicNameCmdName($_object_name, $_eqLogic_name, $_cmd_name) { $values = array( 'eqLogic_name' => $_eqLogic_name, @@ -554,6 +730,14 @@ public static function byObjectNameEqLogicNameCmdName($_object_name, $_eqLogic_n return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get command by object name and command name + * + * @param string $_object_name Object name + * @param string $_cmd_name Command name + * @return static Matching command + * @throws Exception + */ public static function byObjectNameCmdName($_object_name, $_cmd_name) { $values = array( 'object_name' => $_object_name, @@ -568,6 +752,14 @@ public static function byObjectNameCmdName($_object_name, $_cmd_name) { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Get commands by type and subtype + * + * @param string $_type Command type ('action'|'info') + * @param string $_subType Command subtype + * @return static[] Array of matching commands + * @throws Exception + */ public static function byTypeSubType($_type, $_subType = '') { $values = array( 'type' => $_type, @@ -582,6 +774,13 @@ public static function byTypeSubType($_type, $_subType = '') { return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__)); } + /** + * Replace command IDs with human readable format + * + * @param object|array|string $_input Input to convert + * @return object|array|string Converted input + * @throws ReflectionException + */ public static function cmdToHumanReadable($_input) { if (is_object($_input)) { $reflections = array(); @@ -619,6 +818,13 @@ public static function cmdToHumanReadable($_input) { return str_replace(array_keys($replace), $replace, $_input); } + /** + * Replace human readable format with command IDs + * + * @param string|object|array|int|bool|null $_input Input to convert + * @return array|bool|int|mixed|string|string[]|null Converted input + * @throws ReflectionException + */ public static function humanReadableToCmd($_input) { $isJson = false; if (is_json($_input)) { @@ -672,6 +878,14 @@ public static function humanReadableToCmd($_input) { return str_replace(array_keys($replace), $replace, $_input); } + /** + * Get command from string representation + * + * @param string $_string String to convert to command + * @return static Command object + * @throws ReflectionException + * @throws Exception + */ public static function byString($_string) { $cmd = self::byId(str_replace('#', '', self::humanReadableToCmd($_string))); if (!is_object($cmd)) { @@ -680,6 +894,14 @@ public static function byString($_string) { return $cmd; } + /** + * Replace command IDs with their values + * + * @param object|array|string $_input Input to convert + * @param bool $_quote Quote values + * @return object|array|string Converted input + * @throws ReflectionException + */ public static function cmdToValue($_input, $_quote = false) { if (config::byKey('expression::autoQuote', 'core', 1) == 0) { $_quote = false; @@ -744,12 +966,25 @@ public static function cmdToValue($_input, $_quote = false) { return str_replace(array_keys($replace), $replace, $_input); } + /** + * Get all distinct command types + * + * @return string[] Array of command types + * @throws Exception + */ public static function allType() { $sql = 'SELECT distinct(type) as type FROM cmd'; return DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL); } + /** + * Get all distinct command subtypes + * + * @param string $_type Filter by command type + * @return string[] Array of command subtypes + * @throws Exception + */ public static function allSubType($_type = '') { $values = array(); $sql = 'SELECT distinct(subType) as subtype'; @@ -761,12 +996,24 @@ public static function allSubType($_type = '') { return DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL); } + /** + * Get all distinct command units + * + * @return string[] Array of units + * @throws Exception + */ public static function allUnite() { $sql = 'SELECT distinct(unite) as unite FROM cmd'; return DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL); } + /** + * Get all distinct command units + * + * @return string[] Array of units + * @throws Exception + */ public static function convertColor($_color) { $colors = config::byKey('convertColor'); if (isset($colors[$_color])) { @@ -775,6 +1022,12 @@ public static function convertColor($_color) { throw new Exception(__('Impossible de traduire la couleur en code hexadécimal :', __FILE__) . $_color); } + /** + * Get available widgets for version + * + * @param string $_version Version to check + * @return array>>> Available widgets + */ public static function availableWidget($_version) { global $JEEDOM_INTERNAL_CONFIG; $return = array(); @@ -886,6 +1139,16 @@ public static function availableWidget($_version) { return $return; } + /** + * Get widget selection options by type and subtype + * + * @param string|false $_type Command type ('action'|'info'|false) + * @param string|false $_subtype Command subtype + * @param string $_version Widget version + * @param bool $_availWidgets Pre-loaded available widgets + * @return int|string Options HTML string or error code + * @throws Exception + */ public static function getSelectOptionsByTypeAndSubtype($_type = false, $_subtype = false, $_version = 'dashboard', $_availWidgets = false) { if ($_type === false || $_subtype === false) { throw new Exception(__('Type ou sous-type de commande invalide', __FILE__)); @@ -931,6 +1194,12 @@ public static function getSelectOptionsByTypeAndSubtype($_type = false, $_subtyp } } + /** + * Return state after delay + * + * @param array $_options Command options + * @return void + */ public static function returnState($_options) { $cmd = cmd::byId($_options['cmd_id']); if (is_object($cmd)) { @@ -938,6 +1207,11 @@ public static function returnState($_options) { } } + /** + * Find commands without valid references + * + * @return array[] List of dead commands + */ public static function deadCmd() { $return = array(); foreach ((cmd::all()) as $cmd) { @@ -975,6 +1249,12 @@ public static function deadCmd() { return $return; } + /** + * Process command alerts + * + * @param array $_options Command options + * @return void + */ public static function cmdAlert($_options) { $cmd = cmd::byId($_options['cmd_id']); if (!is_object($cmd)) { @@ -984,6 +1264,14 @@ public static function cmdAlert($_options) { } /* * *********************Méthodes d'instance************************* */ + + /** + * Format command value according to its configuration + * + * @param array|object|null|string $_value Value to format + * @param bool $_quote Add quotes around value + * @return float|int|mixed|string Formatted value + */ public function formatValue($_value, $_quote = false) { if (is_array($_value) || is_object($_value)) { return ''; @@ -1056,18 +1344,40 @@ public function formatValue($_value, $_quote = false) { return $_value; } + /** + * Get last stored value + * + * @return mixed|mixed[] Last value + */ public function getLastValue() { return $this->getConfiguration('lastCmdValue', null); } + /** + * Check if command can be removed + * + * @return bool False by default + */ public function dontRemoveCmd() { return false; } + /** + * Get database table name + * + * @return string Table name + */ public function getTableName() { return 'cmd'; } + /** + * Save command to database + * + * @param bool $_direct Direct save without trigger + * @return bool Success status + * @throws Exception + */ public function save($_direct = false) { if ($this->getName() == '') { throw new Exception(__('Le nom de la commande ne peut pas être vide :', __FILE__) . print_r($this, true)); @@ -1126,10 +1436,21 @@ public function save($_direct = false) { return true; } + /** + * Refresh command from database + * + * @return void + * @throws Exception + */ public function refresh() { DB::refresh($this); } + /** + * Remove command + * + * @return bool Success status + */ public function remove() { viewData::removeByTypeLinkId('cmd', $this->getId()); dataStore::removeByTypeLinkId('cmd', $this->getId()); @@ -1147,10 +1468,23 @@ public function remove() { return DB::remove($this); } + /** + * Execute command + * + * @param array $_options Execution options + * @return bool Execution status + */ public function execute($_options = array()) { return false; } + /** + * Execute pre/post command actions + * + * @param array $_values Action values + * @param string $_type Action type ('jeedomPreExecCmd'|'jeedomPostExecCmd') + * @return void + */ private function pre_postExecCmd($_values = array(), $_type = 'jeedomPreExecCmd') { if (!is_array($this->getConfiguration($_type)) || count($this->getConfiguration($_type)) == 0) { @@ -1189,6 +1523,12 @@ private function pre_postExecCmd($_values = array(), $_type = 'jeedomPreExecCmd' } } + /** + * Execute pre-command actions + * + * @param array $_values Action values + * @return void + */ public function preExecCmd($_values = array()) { if (isset($_values['user_login'])) { $this->setCache('lastExecutionUser', $_values['user_login']); @@ -1198,10 +1538,21 @@ public function preExecCmd($_values = array()) { $this->pre_postExecCmd($_values, 'jeedomPreExecCmd'); } + /** + * Execute post-command actions + * + * @param array $_values Action values + * @return void + */ public function postExecCmd($_values = array()) { $this->pre_postExecCmd($_values, 'jeedomPostExecCmd'); } + /** + * Check if command is already in desired state + * + * @return bool State check result + */ public function isAlreadyInStateAllow() { if ($this->getConfiguration('alreadyInState') == 'deny') { return false; @@ -1222,6 +1573,13 @@ public function isAlreadyInStateAllow() { return true; } + /** + * Check if command is in specific state + * + * @param array $_options Command options + * @return bool State verification result + * @throws Exception + */ public function alreadyInState($_options) { if ($this->getSubType() == 'message') { return false; @@ -1254,14 +1612,15 @@ public function alreadyInState($_options) { return false; } - /** - * - * @param null|string $_options - * @param bool $_sendNodeJsEvent - * @param bool $_quote - * @return void|string - * @throws Exception - */ + /** + * Execute command with options + * + * @param null|string|array $_options Execution options + * @param bool $_sendNodeJsEvent Send NodeJS event + * @param bool $_quote Quote values + * @return void|string Command execution result + * @throws Exception + */ public function execCmd($_options = null, $_sendNodeJsEvent = false, $_quote = false) { if ($this->getType() == 'info') { $state = $this->getCache(array('collectDate', 'valueDate', 'value', 'usage')); @@ -1389,6 +1748,14 @@ public function execCmd($_options = null, $_sendNodeJsEvent = false, $_quote = f } // Used by modals eqLogic.dashboard.edit and cmd.configure + /** + * Get widget select options for version + * + * @param string $_version Widget version + * @param bool $_availWidgets Pre-loaded available widgets + * @return string HTML options string + * @throws Exception + */ public function getWidgetsSelectOptions($_version = 'dashboard', $_availWidgets = false) { if (!$_availWidgets) { $_availWidgets = self::availableWidget($_version); @@ -1401,6 +1768,11 @@ public function getWidgetsSelectOptions($_version = 'dashboard', $_availWidgets return $display .= self::getSelectOptionsByTypeAndSubtype($this->getType(), $this->getSubType(), $_version, $_availWidgets); } + /** + * Get generic type select options + * + * @return string HTML options string + */ public function getGenericTypeSelectOptions() { $display = ''; $groups = array(); @@ -1437,6 +1809,13 @@ public function getGenericTypeSelectOptions() { return $display; } + /** + * Get widget help text + * + * @param string $_version Widget version + * @param string $_widgetName Widget name + * @return string Help text + */ public function getWidgetHelp($_version = 'dashboard', $_widgetName = '') { $widget = $this->getWidgetTemplateCode($_version, false, $_widgetName); $widgetCode = $widget['template']; @@ -1460,12 +1839,26 @@ public function getWidgetHelp($_version = 'dashboard', $_widgetName = '') { } } + /** + * Clean widget code from template and helper content + * + * @param string $_template Widget template code + * @return string Cleaned widget code + */ public function cleanWidgetCode($_template) { $_template = preg_replace('/