/**
  * Method to check input data
  *
  * @param array $data Most important to check is $data['data'] field
  * @return bool|string true or error message
  */
 function checkInputData($data)
 {
     if (is_array($data['data'])) {
         foreach ($data['data'] as $number) {
             if (!is_numeric($number) || strpos($data['data'][0], ',') !== false) {
                 return MAX_Plugin_Translation::translate('Geo:Latitude/Longitude: One of the parameter is not a number', $this->extension, $this->group);
             }
         }
     }
     return true;
 }
 /**
  * Method to check input data
  *
  * @param array $data Most important to check is $data['data'] field
  * @return bool|string true or error message
  */
 function checkInputData($data)
 {
     $result = parent::checkInputData($data);
     if ($result === true) {
         //if parent check was OK
         if (is_array($data['data'])) {
             if (strpos($data['data'][0], '|') !== false) {
                 return MAX_Plugin_Translation::translate('Site:Variable: Name contains unallowed character(s)', $this->extension, $this->group);
             }
         }
     }
     return true;
 }
 /**
  * A private method to get the required sub-heading parameters for the reports
  * for a given advertiser/publisher limitation scope.
  *
  * @return array An array of parameters that can be used in the
  *               {@link Plugins_Reports::_getReportParametersForDisplay()} method.
  */
 function _getDisplayableParametersFromScope()
 {
     $aParams = array();
     $key = MAX_Plugin_Translation::translate('Advertiser', $this->module);
     $advertiserId = $this->_oScope->getAdvertiserId();
     if (!empty($advertiserId)) {
         // Get the name of the advertiser
         $doClients = OA_Dal::factoryDO('clients');
         $doClients->clientid = $advertiserId;
         $doClients->find();
         if ($doClients->fetch()) {
             $aAdvertiser = $doClients->toArray();
             $aParams[$key] = $aAdvertiser['clientname'];
         }
     } else {
         if ($this->_oScope->getAnonymous()) {
             $aParams[$key] = MAX_Plugin_Translation::translate('Anonymous Advertisers', $this->module);
         } else {
             $aParams[$key] = MAX_Plugin_Translation::translate('All Advertisers', $this->module);
         }
     }
     $key = MAX_Plugin_Translation::translate('Website', $this->module);
     $publisherId = $this->_oScope->getPublisherId();
     if (!empty($publisherId)) {
         $doAffiliates = OA_Dal::factoryDO('affiliates');
         $doAffiliates->affiliateid = $publisherId;
         $doAffiliates->find();
         if ($doAffiliates->fetch()) {
             $aPublisher = $doAffiliates->toArray();
             $aParams[$key] = $aPublisher['name'];
         }
     } else {
         if ($this->_oScope->getAnonymous()) {
             $aParams[$key] = MAX_Plugin_Translation::translate('Anonymous Publishers', $this->module);
         } else {
             $aParams[$key] = MAX_Plugin_Translation::translate('All Websites', $this->module);
         }
     }
     return $aParams;
 }
 function testIncludePluginLanguageFile()
 {
     $extension = 'nonExistingModule';
     $group = 'nonExistingPackage';
     $language = 'nonExistingLanguage';
     $ret = MAX_Plugin_Translation::includePluginLanguageFile($extension, null, $language);
     $this->assertIdentical($ret, false);
     $this->assertIdentical($GLOBALS['_MAX']['PLUGIN_TRANSLATION'][$extension], array());
     $ret = MAX_Plugin_Translation::includePluginLanguageFile($extension, $group, $language);
     $this->assertIdentical($ret, false);
     $this->assertIdentical($GLOBALS['_MAX']['PLUGIN_TRANSLATION'][$extension][$group], array());
     $translate = 'Some translation string';
     $ret = MAX_Plugin_Translation::translate($translate, $extension, $group);
     // translation wasn't included so should return the same value
     $this->assertIdentical($ret, $translate);
     $path = MAX_PLUGINTRANSLATION_TEST_DIR . '/_lang/';
     include $path . 'en.php';
     $enWords = $words;
     include $path . 'pl.php';
     $plWords = $words;
     $ret = MAX_Plugin_Translation::includePluginLanguageFile($extension, null, 'en', $path);
     $this->assertIdentical($ret, true);
     $this->assertIdentical($GLOBALS['_MAX']['PLUGIN_TRANSLATION'][$extension], $enWords);
     $ret = MAX_Plugin_Translation::translate('translate me', $extension, $group);
     $this->assertIdentical($ret, 'translated text');
     // Clear the translation memory
     unset($GLOBALS['_MAX']['PLUGIN_TRANSLATION']);
     $ret = MAX_Plugin_Translation::includePluginLanguageFile($extension, null, 'pl', $path);
     $this->assertIdentical($ret, true);
     $this->assertIdentical($GLOBALS['_MAX']['PLUGIN_TRANSLATION'][$extension], array_merge($enWords, $plWords));
     // Check that a translation which doesn't exist in the selected language falls through to the english
     $ret = MAX_Plugin_Translation::translate('translate me (fallback to english)', $extension, $group);
     $this->assertIdentical($ret, 'this is from the english pack');
     // Check that a translation key which doesn't exist in selected or english languages returns the key unchanged
     $ret = MAX_Plugin_Translation::translate('this string does not exist in the language packs', $extension, $group);
     $this->assertIdentical($ret, 'this string does not exist in the language packs');
     // Check that the non-existent key with the same name as group returns the key unchanged.
     $ret = MAX_Plugin_Translation::translate($group, $extension, $group);
     $this->assertIdentical($ret, $group);
 }
Exemple #5
0
 /**
  * A private method to return an array containing the start and end dates
  * of a report in a format that is suitable for display in a worksheet's
  * sub-heading.
  *
  * @access private
  * @return array An array containing the Start Date and End Date, if required.
  */
 function _getDisplayableParametersFromDaySpan()
 {
     $aParams = array();
     if (!is_null($this->_oDaySpan)) {
         global $date_format;
         $aParams[MAX_Plugin_Translation::translate('Start Date', $this->module, $this->package)] = $this->_oDaySpan->getStartDateString($date_format);
         $aParams[MAX_Plugin_Translation::translate('End Date', $this->module, $this->package)] = $this->_oDaySpan->getEndDateString($date_format);
     }
     return $aParams;
 }
/**
 * Returns an array where the keys are delivery limitation plugins operators
 * suitable for strings and the values are properly translated strings which
 * describe these operators to the user.
 *
 * @param DeliveryLimitationPlugin $oPlugin
 * @return array Array associating operators with their localized names.
 */
function MAX_limitationsGetAOperationsForString($oPlugin)
{
    return array('==' => $GLOBALS['strEqualTo'], '!=' => $GLOBALS['strDifferentFrom'], '=~' => MAX_Plugin_Translation::translate('Contains', $oPlugin->module, $oPlugin->package), '!~' => MAX_Plugin_Translation::translate('Does not contain', $oPlugin->module, $oPlugin->package), '=x' => MAX_Plugin_Translation::translate('Regex match', $oPlugin->module, $oPlugin->package), '!x' => MAX_Plugin_Translation::translate('Regex does not match', $oPlugin->module, $oPlugin->package));
}
 /**
  * Returns the localized name of the plugin. The method is based
  * on the data stored in nameEnglish member variable.
  *
  * @return string Localized name of the plugin.
  */
 function getName()
 {
     return MAX_Plugin_Translation::translate($this->nameEnglish, $this->extension, $this->group);
 }
 function Plugins_DeliveryLimitations_ArrayData()
 {
     $this->Plugins_DeliveryLimitations();
     $this->aOperations = array('=~' => MAX_Plugin_Translation::translate('Is any of', $this->extension, $this->group), '!~' => MAX_Plugin_Translation::translate('Is not any of', $this->extension, $this->group));
 }
 function __construct()
 {
     parent::__construct();
     $this->aOperations = array('=~' => MAX_Plugin_Translation::translate('Is any of', $this->extension, $this->group), '!~' => MAX_Plugin_Translation::translate('Is not any of', $this->extension, $this->group));
 }
Exemple #10
0
 /**
  * Translates string using module/package translation file
  *
  * @param string $string  String to translate
  * @return string  Translated string
  */
 function translate($string)
 {
     return MAX_Plugin_Translation::translate($string, $this->module, $this->package);
 }