@param null|mixed $mMsg

@return string
198579
public function encodeJson($mMsg = null)
    {
        if (is_string($mMsg)) {
            if (!$this->isUtfString($mMsg)) {
                $mMsg = utf8_encode($mMsg);
            }
        } else {
            // Typecast for Objects
            if (is_object($mMsg)) {
                $mMsg = ( array ) $mMsg;
            }

            $mMsg = $this->_encodeUtf8Array($mMsg);
        }

        return json_encode($mMsg);
    }
106463
public function getMime() {
        switch(strtolower(pathinfo($this->path, PATHINFO_EXTENSION))) {
            case 'json':
                $mime = 'application/json';
                break;
            case 'geojson':
                $mime = 'application/vnd.geo+json';
                break;
            default:
                $mime = @mime_content_type($this->path);
        }
        return $mime;
    }
1155843
public function encode()
    {
        $count = count($this->messages);

        if ($count === 0) {
            return null;
        }

        if ($count === 1) {
            $output = array_shift($this->messages);
        } else {
            $output = $this->messages;
        }

        $this->messages = array();

        return json_encode($output);
    }
227766
function getMagic( $mw ) {
		$this->doMagicHook();

		if ( isset( $this->mMagicExtensions[$mw->mId] ) ) {
			$rawEntry = $this->mMagicExtensions[$mw->mId];
		} else {
			$magicWords = $this->getMagicWords();
			if ( isset( $magicWords[$mw->mId] ) ) {
				$rawEntry = $magicWords[$mw->mId];
			} else {
				$rawEntry = false;
			}
		}

		if ( !is_array( $rawEntry ) ) {
			error_log( "\"$rawEntry\" is not a valid magic word for \"$mw->mId\"" );
		} else {
			$mw->mCaseSensitive = $rawEntry[0];
			$mw->mSynonyms = array_slice( $rawEntry, 1 );
		}
	}
808065
function toMessage($message, $request = null)
    {
        $implicit = $message->isOpenID1();
        $added = $message->namespaces->addAlias($this->ns_uri,
                                                $this->ns_alias,
                                                $implicit);

        if ($added === null) {
            if ($message->namespaces->getAlias($this->ns_uri) !=
                $this->ns_alias) {
                return null;
            }
        }

        if ($request !== null) {
            $message->updateArgs($this->ns_uri,
                                 $this->getExtensionArgs($request));
        } else {
            $message->updateArgs($this->ns_uri,
                                 $this->getExtensionArgs());
        }
        return $message;
    }
1152536
public function getMenuHeaderView(): string
    {
        // Outside of authorized area
        if (!defined('USER_ID') || !USER_ID || !defined('LNG')) {
            return '';
        }

        // Show non-default CMS headers
        $cfg = Configuration::getInstance()->get('cms');
        if (isset($cfg['custom_header']) && $cfg['custom_header']) {
            // Need to create this file prior to use
            return include DIR_MODULES . 'cms/Admin/Menu/getMenuHeaderView.php';
        }

        // Notifications from system
        $notification_repository = new UsersMessageEntityRepository;
        $notification_repository
            ->setWhereToUserId(USER_ID)
            ->setWhereFromUserId(0)
            ->addOrderByField('ts', true)
            ->setWhereSeen(0);

        // All count for number
        $total_notifications = $notification_repository->getCountOfObjectsInCollection();

        // Show a few latest
        $notifications = $notification_repository
            ->setLimit(10)
            ->getAsArrayOfObjects();

        // Messages from users
        $messages_repository = new UsersMessageEntityRepository;
        $messages_repository
            ->setWhereToUserId(USER_ID)
            ->addWhereFieldIsNot('from_user_id', 0)
            ->addOrderByField('ts', true)
            ->setWhereSeen(0);

        // All count for number
        $total_messages = $messages_repository->getCountOfObjectsInCollection();

        $messages = $messages_repository
            ->setLimit(10)
            ->getAsArrayOfObjects();

        // Custom notifiers
        $custom_notifiers = [];

        $custom_notifiers[] = $this->getHelpTextsNotifier();

        // Logo image and link
        $logo = '';
        if (array_key_exists('logo', Configuration::getInstance()->get('cms'))) {
            $logo = Configuration::getInstance()->get('cms')['logo'];
        }

        $logo_link = DIR_CMS_URL;
        if (array_key_exists('logo_link', Configuration::getInstance()->get('cms'))) {
            $logo_link = Configuration::getInstance()->get('cms')['logo_link'];
        }

        // User avatar image
        $user_avatar = Users::getInstance()->getUserData('avatar');
        if (!$user_avatar) {
            $user_avatar = '/vendor/devp-eu/tmcms-core/src/assets/cms/layout/img/avatar.png';
        }

        $languages = AdminLanguages::getPairs();

        ob_start();

        ?>
        <div class="page-header-inner">
            <?php if ($logo): ?>
                <div class="page-logo">
                    <a href="<?= $logo_link ?>">
                        <img src="<?= $logo ?>" alt="logo" class="logo-default">
                    </a>

                    <div class="menu-toggler sidebar-toggler"></div>
                </div>
            <?php endif; ?>
            <a href="javascript:" class="menu-toggler responsive-toggler" data-toggle="collapse"
               data-target=".navbar-collapse"></a>

            <div class="top-menu">
                <ul class="nav navbar-nav pull-right">
                    <li class="dropdown dropdown-extended dropdown-home" id="header_home_bar">
                        <a href="/" target="_blank" class="dropdown-toggle" data-hover="dropdown"
                           data-close-others="true">
                            <i class="cms-icon-globe"></i>
                        </a>
                    </li>
                    <?php if (count($languages) > 1): ?>
                        <li class="dropdown dropdown-language">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown"
                               data-close-others="true">
                                <?php if (Settings::get('show_language_selector_flags')): ?>
                                    <img alt=""
                                         src="/vendor/devp-eu/tmcms-core/src/assets/cms/img/flags/<?= LNG ?>.png">
                                <?php endif; ?>
                                <span class="langname"><?= strtoupper(LNG) ?> </span>
                                <i class="fa fa-angle-down"></i>
                            </a>
                            <ul class="dropdown-menu">
                                <?php foreach ($languages as $k => $v):
                                    if ($k == LNG) {
                                        continue;
                                    }
                                    ?>
                                    <li>
                                        <a href="?p=users&do=_change_lng&lng=<?= $k ?>">
                                            <?php if (Settings::get('show_language_selector_flags')): ?>
                                                <img alt=""
                                                     src="/vendor/devp-eu/tmcms-core/src/assets/cms/img/flags/<?= $k ?>.png">
                                            <?php endif; ?>
                                            <?= $v ?>
                                        </a>
                                    </li>
                                <?php endforeach; ?>
                            </ul>
                        </li>
                    <?php endif; ?>
                    <?php if ($notifications): ?>
                        <li class="dropdown dropdown-extended dropdown-notification" id="header_notification_bar">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown"
                               data-close-others="true">
                                <i class="cms-icon-bell"></i>
                                <span class="badge badge-default"><?= count($notifications); ?></span>
                            </a>
                            <ul class="dropdown-menu">
                                <li>
                                    <p>
                                        You have <?= $total_notifications; ?> new notifications
                                    </p>
                                </li>
                                <li>
                                    <ul class="dropdown-menu-list scroller" style="height: 250px;">
                                        <?php foreach ($notifications as $k => $message): /** @var UsersMessageEntity $message */ ?>
                                            <li>
                                                <a href="#">
                                                    <span class="label label-sm label-icon label-warning">
                                                        <i class="fa fa-bell-o"></i>
                                                    </span>
                                                    <?= $message->getMessage() ?>
                                                    <span class="time">
                                                        <?= Converter::getTimeFromEventAgo((int)$message->getTs()) ?>
                                                    </span>
                                                </a>
                                            </li>
                                        <?php endforeach; ?>
                                    </ul>
                                </li>
                                <li class="external">
                                    <a href="?p=home&do=notifications">
                                        See all notifications <i class="m-icon-swapright"></i>
                                    </a>
                                </li>
                            </ul>
                        </li>
                    <?php endif; ?>
                    <?php if ($messages): ?>
                        <li class="dropdown dropdown-extended dropdown-inbox" id="header_inbox_bar">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown"
                               data-close-others="true">
                                <i class="cms-icon-envelope-open"></i>
                                <span class="badge badge-default"><?= count($messages); ?></span>
                            </a>
                            <ul class="dropdown-menu">
                                <li>
                                    <p>
                                        You have <?= $total_messages; ?> new messages
                                    </p>
                                </li>
                                <li>
                                    <ul class="dropdown-menu-list scroller" style="height: 250px;">
                                        <?php foreach ($notifications as $k => $message): /** @var UsersMessageEntity $message */
                                            $user = new AdminUser($message->getFromUserId());
                                            $avatar = $user->getAvatar(); ?>
                                            <li>
                                                <a href="?p=users&do=chat&user_id=2">
                                                    <?php if ($avatar): ?>
                                                        <span class="photo">
                                                           <img src="<?= $avatar ?>" alt="" style="height=40px">
                                                        </span>
                                                    <?php endif; ?>
                                                    <span class="subject">
                                                        <span class="from"><?= $user->getName() ?></span>
                                                        <span class="time"><?= Converter::getTimeFromEventAgo((int)$message->getTs()) ?></span>
                                                    </span>
                                                    <span class="message"><?= Converter::cutLongStrings($message->getMessage()) ?></span>
                                                </a>
                                            </li>
                                        <?php endforeach; ?>
                                    </ul>
                                </li>
                                <li class="external">
                                    <a href="?p=users&do=chat">
                                        See all messages <i class="m-icon-swapright"></i>
                                    </a>
                                </li>
                            </ul>
                        </li>
                    <?php endif; ?>
                    <?php if ($custom_notifiers): ?>
                        <?= implode('', $custom_notifiers) ?>
                    <?php endif; ?>
                    <li class="dropdown dropdown-user">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown"
                           data-close-others="true">
                            <img alt="" class="img-circle" src="<?= $user_avatar ?>" style="height: 29px;">
                            <span class="username"><?= Users::getInstance()->getUserData('name') ?></span>
                            <i class="fa fa-angle-down"></i>
                        </a>
                        <ul class="dropdown-menu">
                            <li>
                                <a href="?p=users&do=users_edit&id=<?= USER_ID ?>">
                                    <i class="cms-icon-user"></i> My Profile
                                </a>
                            </li>
                            <li>
                                <a href="?p=home&do=notifications">
                                    <i class="cms-icon-envelope-open"></i>My notifications
                                    <span class="badge badge-danger"> <?= count($notifications) ?></span>
                                </a>
                            </li>
                            <li class="divider"></li>
                            <li>
                                <a href="#" onclick="clipboard_forms.copy_page_forms(); return false;">
                                    <i class="cms-icon-cloud-download"></i>Copy form data
                                </a>
                            </li>
                            <li>
                                <a href="#" onclick="clipboard_forms.paste_page_forms(); return false;">
                                    <i class="cms-icon-cloud-upload"></i>Paste form data
                                </a>
                            </li>
                            <li class="divider"></li>
                            <li>
                                <a href="?p=home&do=_exit" onclick="return confirm('<?= __('Are you sure?') ?>');">
                                    <i class="cms-icon-key"></i> Log Out
                                </a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <?php

        return ob_get_clean();
    }
1250433
protected function sendTextMsgToJsonString(WxSendTextMsg $msg)
    {
        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "text":
                        {
                             "content":"%s"
                        }
                    }';
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $msg->getContent()
                        );


        return $result;
    }
889488
public function getMsgBody()
    {
        $body = null;

        if (!empty($this->_parts)) {
            if (count($this->_parts) > 1) {
                foreach ($this->_parts as $part) {
                    if ($part->contentType != Content::CT_TEXT_PLAIN && $this->getHeaders()->getMessageContentType() == Content::CT_MULTIPART_ALTERNATIVE) {
                        $body = $part->getContentDecode();
                        break;
                    }

                    $body .= PHP_EOL.$part->getContentDecode();
                }
            } else {
                $body = $this->_parts[0]->getContentDecode();
            }
        }

        return $body;
    }
511131
public function getMessage()
    {
        return isset($this->data['ErrorMsg']) && !empty($this->data['ErrorMsg']) ? $this->data['ErrorMsg'] : null;
    }
107233
protected function readdmesg()
    {
        if (count($this->_dmesg) === 0) {
            if (PSI_OS != "Darwin") {
                if (CommonFunctions::rfts('/var/run/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/log/dmesg.boot', $buf, 0, 4096, false) || CommonFunctions::rfts('/var/run/dmesg.boot', $buf)) {  // Once again but with debug
                    $parts = preg_split("/rebooting|Uptime/", $buf, -1, PREG_SPLIT_NO_EMPTY);
                    $this->_dmesg = preg_split("/\n/", $parts[count($parts) - 1], -1, PREG_SPLIT_NO_EMPTY);
                }
            }
        }

        return $this->_dmesg;
    }
125931
static public function success($errmsg=null, $data=null)
    {
        if (is_array($errmsg) || $errmsg instanceof Collection ) {
            $object = static::instance(0, null, $errmsg);
            $data && $object->set($data);
        } else {
            $object = static::instance(0, $errmsg, $data);
        }
        
        return $object->set('errcode', 0);
    }
971917
private function checkMessage($defMsg, array $options) {
        if (is_array($options) && isset($options['message']))
            return $options['message'] ? $options['message'] : null;

        return $defMsg;
    }
1211476
public function formatMsisdn($phone_number = '', $format = NULL)
    {
        if (empty($phone_number)) {
            return NULL;
        }
        try {
            if (mb_strpos('*', $phone_number) || mb_strpos('x', $phone_number)) {
                return $phone_number;
            } else {
                if (self::MSISDN_FORMAT_MODE == 'new' || self::MSISDN_FORMAT_MODE == 'old') {
                    $BasePhoneNumber = new BasePhoneNumber();
                    $phone_number    = $BasePhoneNumber->phone_number_convert($phone_number, self::MSISDN_FORMAT_MODE, $format);
                } else {
                    $phone_number = $this->phoneNumber->format($phone_number, $format);
                }

                return $phone_number;
            }
        }
        catch (\Exception $e) {
            return $phone_number;
        }
    }
884725
public function toString()
    {
        $email = $this->sender ? $this->sender->getEmail() : "null";

        $request = array();
        $request['Reference'] = $this->reference;
        $request['SenderEmail'] = $email;

        return "PagSeguroRequest: " . var_export($request, true);
    }
436642
public function getSignature($domain, $user)
    {
        $url = self::BASE_URL . "{$domain}/{$user}/signature";
        $request = new \Google_Http_Request($url, 'GET', null, null);

        $httpRequest = $this->helper->getClient()
           ->getAuth()
           ->authenticatedRequest($request);
        if ($httpRequest->getResponseHttpCode() == 200) {
            $xmlResponse = new \SimpleXMLElement($httpRequest->getResponseBody(), 0, false, 'apps', true);

            return (string)$xmlResponse->children('apps', true)
               ->attributes()->value;
        } else {
            // An error occurred.
            return null;
        }
    }
807895
protected function buildSMSString()
    {
        $sms = $this->prefix.$this->phoneNumber;

        if (isset($this->message)) {
            $sms .= $this->separator.$this->message;
        }

        return $sms;
    }
1055439
public function getFormattedMessage()
    {
        $message = "";
        $message .= "[HTTP " . $this->httpStatus->getStatus() . "] - " . $this->getHttpMessage() . "\n";
        foreach ($this->errors as $key => $value) {
            if ($value instanceof PagSeguroError) {
                $message .= "$key [" . $value->getCode() . "] - " . $value->getMessage();
            }
        }
        return $message;
    }