protected function getOptions() { MLog::add('MFormFieldEditors is deprecated. Use MFormFieldPlugins instead (with folder="editors").', MLog::WARNING, 'deprecated'); // Get the database object and a new query object. $db = MFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->quote('editors')); $query->where('enabled = 1'); $query->order('ordering, name'); // Set the query and load the options. $db->setQuery($query); $options = $db->loadObjectList(); $lang = MFactory::getLanguage(); foreach ($options as $i => $option) { $lang->load('plg_editors_' . $option->value, MPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_editors_' . $option->value, MPATH_PLUGINS . '/editors/' . $option->value, null, false, false) || $lang->load('plg_editors_' . $option->value, MPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_editors_' . $option->value, MPATH_PLUGINS . '/editors/' . $option->value, $lang->getDefault(), false, false); $options[$i]->text = MText::_($option->text); } // Check for a database error. if ($db->getErrorNum()) { MError::raiseWarning(500, $db->getErrorMsg()); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
public function stringToObject($data, $options = array('processSections' => false)) { // Fix legacy API. if (is_bool($options)) { $options = array('processSections' => $options); // Deprecation warning. MLog::add('MRegistryFormatJSON::stringToObject() second argument should not be a boolean.', MLog::WARNING, 'deprecated'); } $data = trim($data); if (substr($data, 0, 1) != '{' && substr($data, -1, 1) != '}') { $ini = MRegistryFormat::getInstance('INI'); $obj = $ini->stringToObject($data, $options); } else { $obj = json_decode($data); } return $obj; }
public function return_bytes($val) { // Deprecation warning. MLog::add('MUtility::return_bytes() is deprecated.', MLog::WARNING, 'deprecated'); $val = trim($val); $last = strtolower($val[strlen($val) - 1]); switch ($last) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; }
public static function getInstance($type, $prefix = '', $config = array()) { $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $modelClass = $prefix . ucfirst($type); if (!class_exists($modelClass)) { mimport('mivi.filesystem.path'); $path = MPath::find(self::addIncludePath(null, $prefix), self::_createFileName('model', array('name' => $type))); if (!$path) { $path = MPath::find(self::addIncludePath(null, ''), self::_createFileName('model', array('name' => $type))); } if ($path) { require_once $path; if (!class_exists($modelClass)) { MLog::add(MText::sprintf('MLIB_APPLICATION_ERROR_MODELCLASS_NOT_FOUND', $modelClass), MLog::WARNING, 'merror'); return false; } } else { return false; } } return new $modelClass($config); }
public static function administrator($file, $folder = '/images/', $altFile = null, $altFolder = '/images/', $alt = null, $attribs = null, $asTag = true) { // Deprecation warning. MLog::add('MImage::administrator is deprecated.', MLog::WARNING, 'deprecated'); $app = MFactory::getApplication(); if (is_array($attribs)) { $attribs = MArrayHelper::toString($attribs); } $cur_template = $app->getTemplate(); // Strip HTML. $alt = html_entity_decode($alt, ENT_COMPAT, 'UTF-8'); if ($altFile) { $image = $altFolder . $altFile; } elseif ($altFile == -1) { $image = ''; } else { if (file_exists(MPATH_ADMINISTRATOR . '/templates/' . $cur_template . '/images/' . $file)) { $image = 'templates/' . $cur_template . '/images/' . $file; } else { // Compatibility with previous versions. if (substr($folder, 0, 14) == "/administrator") { $image = substr($folder, 15) . $file; } else { $image = $folder . $file; } } } if (substr($image, 0, 1) == "/") { $image = substr_replace($image, '', 0, 1); } // Prepend the base path. $image = MURI::base(true) . '/' . $image; // Outputs actual HTML <img> tag. if ($asTag) { $image = '<img src="' . $image . '" alt="' . $alt . '" ' . $attribs . ' />'; } return $image; }
public function asFormattedXML($compressed = false, $indent = "\t", $level = 0) { MLog::add('MXMLElement::asFormattedXML() is deprecated, use SimpleXMLElement::asXML() instead.', MLog::WARNING, 'deprecated'); $out = ''; // Start a new line, indent by the number indicated in $level $out .= $compressed ? '' : "\n" . str_repeat($indent, $level); // Add a <, and add the name of the tag $out .= '<' . $this->getName(); // For each attribute, add attr="value" foreach ($this->attributes() as $attr) { $out .= ' ' . $attr->getName() . '="' . htmlspecialchars((string) $attr, ENT_COMPAT, 'UTF-8') . '"'; } // If there are no children and it contains no data, end it off with a /> if (!count($this->children()) && !(string) $this) { $out .= " />"; } else { // If there are children if (count($this->children())) { // Close off the start tag $out .= '>'; $level++; // For each child, call the asFormattedXML function (this will ensure that all children are added recursively) foreach ($this->children() as $child) { $out .= $child->asFormattedXML($compressed, $indent, $level); } $level--; // Add the newline and indentation to go along with the close tag $out .= $compressed ? '' : "\n" . str_repeat($indent, $level); } elseif ((string) $this) { // If there is data, close off the start tag and add the data $out .= '>' . htmlspecialchars((string) $this, ENT_COMPAT, 'UTF-8'); } // Add the end tag $out .= '</' . $this->getName() . '>'; } return $out; }
public static function access(&$row, $i, $archived = null) { // Deprecation warning. MLog::add('MGrid::access is deprecated.', MLog::WARNING, 'deprecated'); // TODO: This needs to be reworked to suit the new access levels if ($row->access <= 1) { $color_access = 'class="allow"'; $task_access = 'accessregistered'; } elseif ($row->access == 1) { $color_access = 'class="deny"'; $task_access = 'accessspecial'; } else { $color_access = 'class="none"'; $task_access = 'accesspublic'; } if ($archived == -1) { $href = MText::_($row->groupname); } else { $href = ' <a href="javascript:void(0);" onclick="return listItemTask(\'cb' . $i . '\',\'' . $task_access . '\')" ' . $color_access . '> ' . MText::_($row->groupname) . '</a>'; } return $href; }
public function addEntry($entry) { // Deprecation warning. MLog::add('MLog::addEntry() is deprecated, use MLog::add() instead.', MLog::WARNING, 'deprecated'); // Easiest case is we already have a MLogEntry object to add. if ($entry instanceof MLogEntry) { return $this->addLogEntry($entry); } elseif (is_array($entry) || is_object($entry)) { $tmp = new MLogEntry(''); foreach ((array) $entry as $k => $v) { switch ($k) { case 'c-ip': $tmp->clientIP = $v; break; case 'status': $tmp->category = $v; break; case 'level': $tmp->priority = $v; break; case 'comment': $tmp->message = $v; break; default: $tmp->{$k} = $v; break; } } } else { return false; } return $this->addLogEntry($tmp); }
public static function core($debug = null) { MLog::add('MHtml::core() is deprecated. Use MHtml::_(\'behavior.framework\');.', MLog::WARNING, 'deprecated'); MHtml::_('behavior.framework', false, $debug); }
public function setError($error) { // Deprecation warning. MLog::add('MException::setErrors is deprecated.', MLog::WARNING, 'deprecated'); array_push($this->_errors, $error); }
public static function category($name, $extension, $selected = null, $javascript = null, $order = null, $size = 1, $sel_cat = 1) { // Deprecation warning. MLog::add('MList::category is deprecated.', MLog::WARNING, 'deprecated'); $categories = MHtml::_('category.options', $extension); if ($sel_cat) { array_unshift($categories, MHtml::_('select.option', '0', MText::_('MOPTION_SELECT_CATEGORY'))); } $category = MHtml::_('select.genericlist', $categories, $name, 'class="inputbox" size="' . $size . '" ' . $javascript, 'value', 'text', $selected); return $category; }
public function toString() { // Deprecation warning. MLog::add('MObject::toString() is deprecated.', MLog::WARNING, 'deprecated'); return $this->__toString(); }
public function saveorder($pks = null, $order = null) { $table = $this->getTable(); $conditions = array(); if (empty($pks)) { return MError::raiseWarning(500, MText::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED')); } // Update ordering values foreach ($pks as $i => $pk) { $table->load((int) $pk); // Access checks. if (!$this->canEditState($table)) { // Prune items that you can't change. unset($pks[$i]); MLog::add(MText::_('MLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), MLog::WARNING, 'merror'); } elseif ($table->ordering != $order[$i]) { $table->ordering = $order[$i]; if (!$table->store()) { $this->setError($table->getError()); return false; } // Remember to reorder within position and client_id $condition = $this->getReorderConditions($table); $found = false; foreach ($conditions as $cond) { if ($cond[1] == $condition) { $found = true; break; } } if (!$found) { $key = $table->getKeyName(); $conditions[] = array($table->{$key}, $condition); } } } // Execute reorder for each category. foreach ($conditions as $cond) { $table->load($cond[0]); $table->reorder($cond[1]); } // Clear the component's cache $this->cleanCache(); return true; }
public function toXML($mapKeysToText = false) { // Deprecation warning. MLog::add('MTable::toXML() is deprecated.', MLog::WARNING, 'deprecated'); // Initialise variables. $xml = array(); $map = $mapKeysToText ? ' mapkeystotext="true"' : ''; // Open root node. $xml[] = '<record table="' . $this->_tbl . '"' . $map . '>'; // Get the publicly accessible instance properties. foreach (get_object_vars($this) as $k => $v) { // If the value is null or non-scalar, or the field is internal ignore it. if (!is_scalar($v) || $v === null || $k[0] == '_') { continue; } $xml[] = ' <' . $k . '><![CDATA[' . $v . ']]></' . $k . '>'; } // Close root node. $xml[] = '</record>'; // Return the XML array imploded over new lines. return implode("\n", $xml); }
public static function parseXMLInstallFile($path) { MLog::add('MApplicationHelper::parseXMLInstallFile is deprecated. Use MInstaller::parseXMLInstallFile instead.', MLog::WARNING, 'deprecated'); // Read the file to see if it's a valid component XML file if (!($xml = MFactory::getXML($path))) { return false; } // Check for a valid XML root tag. // Should be 'install', but for backward compatibility we will accept 'extension'. // Languages use 'metafile' instead if ($xml->getName() != 'install' && $xml->getName() != 'extension' && $xml->getName() != 'metafile') { unset($xml); return false; } $data = array(); $data['legacy'] = $xml->getName() == 'mosinstall' || $xml->getName() == 'install'; $data['name'] = (string) $xml->name; // Check if we're a language. If so use metafile. $data['type'] = $xml->getName() == 'metafile' ? 'language' : (string) $xml->attributes()->type; $data['creationDate'] = (string) $xml->creationDate ? (string) $xml->creationDate : MText::_('Unknown'); $data['author'] = (string) $xml->author ? (string) $xml->author : MText::_('Unknown'); $data['copyright'] = (string) $xml->copyright; $data['authorEmail'] = (string) $xml->authorEmail; $data['authorUrl'] = (string) $xml->authorUrl; $data['version'] = (string) $xml->version; $data['description'] = (string) $xml->description; $data['group'] = (string) $xml->group; return $data; }
public function loadSetupFile() { // Deprecation warning. MLog::add('MRegistry::loadSetupFile() is deprecated.', MLog::WARNING, 'deprecated'); return true; }
public function setAccessControl($section, $value = null) { // Deprecation warning. MLog::add('MController::setAccessControl() is deprecated.', MLog::WARNING, 'deprecated'); $this->_acoSection = $section; $this->_acoSectionValue = $value; }
public static function optgroup($text, $optKey = 'value', $optText = 'text') { // Deprecation warning. MLog::add('MSelect::optgroup is deprecated.', MLog::WARNING, 'deprecated'); // Set initial state static $state = 'open'; // Toggle between open and close states: switch ($state) { case 'open': $obj = new stdClass(); $obj->{$optKey} = '<OPTGROUP>'; $obj->{$optText} = $text; $state = 'close'; break; case 'close': $obj = new stdClass(); $obj->{$optKey} = '</OPTGROUP>'; $obj->{$optText} = $text; $state = 'open'; break; } return $obj; }
public static function renderBacktrace($error) { // Deprecation warning. MLog::add('MError::renderBacktrace() is deprecated.', MLog::WARNING, 'deprecated'); $contents = null; $backtrace = $error->getTrace(); if (is_array($backtrace)) { ob_start(); $j = 1; echo '<table cellpadding="0" cellspacing="0" class="Table">'; echo ' <tr>'; echo ' <td colspan="3" class="TD"><strong>Call stack</strong></td>'; echo ' </tr>'; echo ' <tr>'; echo ' <td class="TD"><strong>#</strong></td>'; echo ' <td class="TD"><strong>Function</strong></td>'; echo ' <td class="TD"><strong>Location</strong></td>'; echo ' </tr>'; for ($i = count($backtrace) - 1; $i >= 0; $i--) { echo ' <tr>'; echo ' <td class="TD">' . $j . '</td>'; if (isset($backtrace[$i]['class'])) { echo ' <td class="TD">' . $backtrace[$i]['class'] . $backtrace[$i]['type'] . $backtrace[$i]['function'] . '()</td>'; } else { echo ' <td class="TD">' . $backtrace[$i]['function'] . '()</td>'; } if (isset($backtrace[$i]['file'])) { echo ' <td class="TD">' . $backtrace[$i]['file'] . ':' . $backtrace[$i]['line'] . '</td>'; } else { echo ' <td class="TD"> </td>'; } echo ' </tr>'; $j++; } echo '</table>'; $contents = ob_get_contents(); ob_end_clean(); } return $contents; }
public function toString($whitespace = true) { // Deprecation warning. MLog::add('MSimpleXMLElement::toString() is deprecated.', MLog::WARNING, 'deprecated'); // Start a new line, indent by the number indicated in $this->level, add a <, and add the name of the tag if ($whitespace) { $out = "\n" . str_repeat("\t", $this->_level) . '<' . $this->_name; } else { $out = '<' . $this->_name; } // For each attribute, add attr="value" foreach ($this->_attributes as $attr => $value) { $out .= ' ' . $attr . '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"'; } // If there are no children and it contains no data, end it off with a /> if (empty($this->_children) && empty($this->_data)) { $out .= " />"; } else { // If there are children if (!empty($this->_children)) { // Close off the start tag $out .= '>'; // For each child, call the asXML function (this will ensure that all children are added recursively) foreach ($this->_children as $child) { $out .= $child->toString($whitespace); } // Add the newline and indentation to go along with the close tag if ($whitespace) { $out .= "\n" . str_repeat("\t", $this->_level); } } elseif (!empty($this->_data)) { $out .= '>' . htmlspecialchars($this->_data, ENT_COMPAT, 'UTF-8'); } // Add the end tag $out .= '</' . $this->_name . '>'; } //Return the final output return $out; }
protected static function _getJSObject($array = array()) { MLog::add('MHtmlBehavior::_getJSObject() is deprecated. MHtml::getJSObject() instead..', MLog::WARNING, 'deprecated'); return MHtml::getJSObject($array); }
protected static function _createDbo() { MLog::add(__METHOD__ . '() is deprecated.', MLog::WARNING, 'deprecated'); return self::createDbo(); }
public function authorisedLevels() { // Deprecation warning. MLog::add('MUser::authorisedLevels() is deprecated.', MLog::WARNING, 'deprecated'); return $this->getAuthorisedViewLevels(); }
public function stderr($showSQL = false) { // Deprecation warning. MLog::add('MDatabase::stderr() is deprecated.', MLog::WARNING, 'deprecated'); if ($this->errorNum != 0) { return MText::sprintf('MLIB_DATABASE_ERROR_FUNCTION_FAILED', $this->errorNum, $this->errorMsg) . ($showSQL ? "<br />SQL = <pre>{$this->sql}</pre>" : ''); } else { return MText::_('MLIB_DATABASE_FUNCTION_NOERROR'); } }
public function getFeature($feature) { MLog::add('MBrowser::getFeature() is deprecated.', MLog::WARNING, 'deprecated'); return isset($this->_features[$feature]) ? $this->_features[$feature] : null; }
public function queryBatch($abortOnError = true, $transactionSafe = false) { // Deprecation warning. MLog::add('MDatabaseMySQL::queryBatch() is deprecated.', MLog::WARNING, 'deprecated'); $sql = $this->replacePrefix((string) $this->sql); $this->errorNum = 0; $this->errorMsg = ''; // If the batch is meant to be transaction safe then we need to wrap it in a transaction. if ($transactionSafe) { $sql = 'START TRANSACTION;' . rtrim($sql, "; \t\r\n") . '; COMMIT;'; } $queries = $this->splitSql($sql); $error = 0; foreach ($queries as $query) { $query = trim($query); if ($query != '') { $this->cursor = mysql_query($query, $this->connection); if ($this->debug) { $this->count++; $this->log[] = $query; } if (!$this->cursor) { $error = 1; $this->errorNum .= mysql_errno($this->connection) . ' '; $this->errorMsg .= mysql_error($this->connection) . " SQL={$query} <br />"; if ($abortOnError) { return $this->cursor; } } } } return $error ? false : true; }
public static function _parseXMLLanguageFiles($dir = null) { // Deprecation warning. MLog::add('MLanguage::_parseXMLLanguageFiles() is deprecated.', MLog::WARNING, 'deprecated'); return self::parseXMLLanguageFiles($dir); }