public function __construct($oReferencedObject, $sDefaultLanguageId = null) { $aMessageParameters = array(); foreach ($oReferencedObject->getReferees() as $oReferee) { $oFrom = $oReferee->getFrom(); $aFrom = array(); $aFrom["model"] = $oReferee->getFromModelName(); $aFrom["name"] = Util::descriptionForObject($oFrom, $sDefaultLanguageId); if (!$oFrom instanceof LanguageObject) { $aFrom["name"] = $aFrom["model"] . ': ' . $aFrom["name"]; } if (method_exists($oFrom, 'getAdminWidget')) { $oWidget = $oFrom->getAdminWidget(); $aFrom["admin_widget"] = array($oWidget->getModuleName(), $oWidget->getSessionKey()); } elseif (method_exists($oFrom, 'getAdminLink')) { $aFrom["admin_link"] = LinkUtil::link($oFrom->getAdminLink(), 'AdminManager'); } $aMessageParameters['references'][] = $aFrom; } $aMessageParameters['to'] = Util::nameForObject($oReferencedObject); parent::__construct('wns.still_referenced.message', $aMessageParameters, null, 0, $sDefaultLanguageId); }
private function textForReplaceIdentifier(&$iFlags, $mText) { $sResult = null; if ($mText instanceof Template) { $mText = clone $mText; $sResult = $mText->render(); } else { if (is_string($mText)) { $sResult = $mText; } else { if (is_array($mText)) { $sResult = implode('', $mText); } else { if (is_float($mText)) { $sResult = sprintf('%f', $mText); } else { if (is_numeric($mText)) { $sResult = sprintf('%d', $mText); } else { if (is_object($mText)) { $sResult = Util::descriptionForObject($mText); } else { if (is_bool($mText)) { $sResult = $mText ? "true" : "false"; } } } } } } } return $sResult; }
private function getTextForReplaceIdentifier($mText, $iFlags = 0) { $iFlags = $iFlags | $this->iDefaultFlags; $aText = array(); if ($mText instanceof Template) { $mText = clone $mText; if (($iFlags & self::LEAVE_IDENTIFIERS) !== self::LEAVE_IDENTIFIERS) { $mText->bKillIdentifiersBeforeRender = true; $mText->prepareForRender(); } $aText = $mText->aTemplateContents; foreach ($aText as $mTextItem) { if ($mTextItem instanceof TemplatePart) { $mTextItem->setTemplate($this); } } } else { if (is_string($mText)) { $aText[] = $mText; } else { if (is_array($mText)) { $aText = $mText; } else { if (is_float($mText)) { $aText[] = sprintf('%f', $mText); } else { if (is_numeric($mText)) { $aText[] = sprintf('%d', $mText); } else { if (is_callable($mText)) { $aText = $this->getTextForReplaceIdentifier($mText(), $iFlags); } else { if (is_object($mText)) { $sObjectDescription = Util::descriptionForObject($mText); if (!$sObjectDescription) { $sObjectDescription = (string) $mText; } $aText[] = $sObjectDescription; } else { if (is_bool($mText)) { $aText[] = $mText ? "true" : "false"; } } } } } } } } foreach ($aText as $iKey => $sText) { if ($aText[$iKey] instanceof TemplateIdentifier) { continue; } if (!$mText instanceof Template && ($iFlags & self::NO_RECODE) !== self::NO_RECODE) { $aText[$iKey] = StringUtil::encode($aText[$iKey], Settings::getSetting('encoding', 'db', 'utf-8'), $this->sEncoding); } if (($iFlags & self::ESCAPE) === self::ESCAPE && (!$mText instanceof Template || ($mText->iDefaultFlags & self::ESCAPE) !== self::ESCAPE)) { $aText[$iKey] = str_replace("\n", "\\n", addslashes($aText[$iKey])); } if (($iFlags & self::URL_ENCODE) === self::URL_ENCODE && (!$mText instanceof Template || ($mText->iDefaultFlags & self::URL_ENCODE) !== self::URL_ENCODE)) { $aText[$iKey] = urlencode($aText[$iKey]); } if (($iFlags & self::JAVASCRIPT_CONVERT) === self::JAVASCRIPT_CONVERT && (!$mText instanceof Template || ($mText->iDefaultFlags & self::JAVASCRIPT_CONVERT) !== self::JAVASCRIPT_CONVERT)) { $aText[$iKey] = '"' . $aText[$iKey] . '"'; } if (($iFlags & self::FORCE_HTML_ESCAPE) === self::FORCE_HTML_ESCAPE || ($iFlags & self::NO_HTML_ESCAPE) !== self::NO_HTML_ESCAPE && !$mText instanceof Template) { $aText[$iKey] = self::htmlEncode($aText[$iKey]); } if (($iFlags & self::CONVERT_NEWLINES_TO_BR) === self::CONVERT_NEWLINES_TO_BR && (!$mText instanceof Template || ($mText->iDefaultFlags & self::CONVERT_NEWLINES_TO_BR) !== self::CONVERT_NEWLINES_TO_BR)) { $aText[$iKey] = nl2br($aText[$iKey]); } if (($iFlags & self::LEAVE_IDENTIFIERS) === self::LEAVE_IDENTIFIERS && !$mText instanceof Template) { $aText = self::templateContentsFromText($aText[$iKey], $this); //only allowed once break; } } if (($iFlags & self::STRIP_TAGS) === self::STRIP_TAGS) { $aText = array(strip_tags(implode('', $aText))); } return $aText; }