/** * Gets menu items by attribute * * @param string $attributes The field name * @param string $values The value of the field * @param boolean $firstonly If true, only returns the first item found * * @return array * * @since 1.6 */ public function getItems($attributes, $values, $firstonly = false) { $attributes = (array) $attributes; $values = (array) $values; if ($this->app->isSite()) { // Filter by language if not set if (($key = array_search('language', $attributes)) === false) { if (JLanguageMultilang::isEnabled()) { $attributes[] = 'language'; $values[] = array($this->language->getTag(), '*'); } } elseif ($values[$key] === null) { unset($attributes[$key]); unset($values[$key]); } // Filter by access level if not set if (($key = array_search('access', $attributes)) === false) { $attributes[] = 'access'; $values[] = $this->user->getAuthorisedViewLevels(); } elseif ($values[$key] === null) { unset($attributes[$key]); unset($values[$key]); } } // Reset arrays or we get a notice if some values were unset $attributes = array_values($attributes); $values = array_values($values); return parent::getItems($attributes, $values, $firstonly); }
/** * Test... * * @covers JLanguage::getTag * @todo Implement testGetTag(). * * @return void */ public function testGetTag() { $this->assertEquals( 'en-GB', $this->object->getTag() ); // Remove the following lines when you implement this test. $this->markTestIncomplete( 'This test has not been implemented yet.' ); }
/** * Test... * * @return void */ public function testGetTag() { $this->assertEquals('en-GB', $this->object->getTag()); }
/** * Iterates through string to replace every * {placeholder} with row data * (added by hugh, does the same thing as parseMessageForPlaceHolder in parent * class, but for rows instead of forms) * * NOTE - I can't remember why I added this way back when in 2.x, instead of using the helper function, * I just know there was a good reason, to do with the helper func making assumptions about something * (I think to do with how form data is formatted) which weren't true when rendering list data. I have * a suspicion that in the intervening years, the helper func and the way we format data may now be * copacetic, and we could do away with this separation, and just use the normal helper func. Might be * worth testing, as this code looks like it has suffered bitrot, and doesn't do a number of things the main * helper func now does. * * @param string $msg text to parse * @param array &$row of row data * @param bool $addSlashes add slashes to the replaced data (default = false) set to true in fabrikcalc element * * @return string parsed message */ public function parseMessageForRowHolder($msg, &$row, $addSlashes = false) { $this->aRow = $row; if (!strstr($msg, '{')) { return $msg; } $this->parseAddSlases = $addSlashes; $msg = FabrikWorker::replaceWithUserData($msg); $msg = FabrikWorker::replaceWithGlobals($msg); $msg = preg_replace("/{}/", "", $msg); $this->rowIdentifierAdded = false; /* replace {element name} with form data */ /* $$$ hugh - testing changing the regex so we don't blow away PHP structures! Added the \s so * we only match non-space chars in {}'s. So unless you have some code like "if (blah) {foo;}", PHP * block level {}'s should remain unmolested. */ $msg = preg_replace_callback("/{[^}\\s]+}/i", array($this, 'replaceWithRowData'), $msg); $lang = $this->lang->getTag(); $lang = str_replace('-', '_', $lang); $msg = str_replace('{lang}', $lang, $msg); return $msg; }
/** * @todo Implement testGetTag(). */ public function testGetTag() { // This method get language tag $lang = new JLanguage(''); // In this case, returns en-GB (default language) // - same operation of get method with tag property $this->assertEquals('en-GB', $lang->getTag(), 'Line: ' . __LINE__); $this->assertNotEquals('es-ES', $lang->getTag(), 'Line: ' . __LINE__); }