/** * Constructor * * @param array Associative array of values */ public function __construct(KConfig $options) { //Load koowa javascript //@TODO get rid of JHTML depencies if (KFactory::get('admin::com.ninja.helper.default')->framework() != 'jquery') { KTemplateHelper::factory('behavior')->mootools(); } $this->set($options->append(array('name' => KRequest::get('get.view', 'cmd', 'items')))->toArray()); }
/** * Get the locked information * * @return string The locked information as an internationalised string */ public function lockMessage() { $message = ''; if($this->locked()) { $user = KFactory::get('joomla:user', array($this->locked_by)); $date = KTemplateHelper::factory('date')->humanize(array('date' => $this->locked_on)); $message = JText::sprintf('Locked by %s %s', $user->get('name'), $date); } return $message; }
/** * Get a template helper * * @param mixed An object that implements KObjectIdentifiable, an object that * implements KIdentifierInterface or valid identifier string * @param mixed Parameters to be passed to the helper * @return KTemplateHelperInterface */ public function getHelper($helper) { //Create the complete identifier if a partial identifier was passed if(is_string($helper) && strpos($helper, '.') === false ) { $identifier = clone $this->getIdentifier(); $identifier->path = array('template','helper'); $identifier->name = $helper; } else $identifier = KFactory::identify($helper); //Create the template helper $helper = KTemplateHelper::factory($identifier, array('template' => $this)); return $helper; }
<form action="<?= @route('view=user') ?>" method="post" name="login" id="form-login"> <input type="hidden" name="action" value="login" /> <p id="form-login-username"> <label for="username"> <?= @text('Username') ?><br /> <input name="username" id="username" type="text" class="inputbox" size="20" autofocus="autofocus" placeholder="<?= @text('Username') ?>" /> </label> </p> <p id="form-login-password"> <label for="password"><?= @text('Password') ?></label><br /> <input name="password" type="password" id="password" class="inputbox" size="15" placeholder="<?= @text('Password') ?>" /> </p> <p id="form-login-site"> <label for="modlgn_site"><?php echo JText::_('Site'); ?></label><br /> <?= KTemplateHelper::factory('com://admin/sites.template.helper.listbox')->sites(array('attribs' => array('class' => 'inputbox'))); ?> </p> <? if($error = JError::getError(true)) : ?> <p id="login-error-message"><?= $error->get('message') ?></p> <? endif ?> <div class="button_holder"> <div class="button1"> <a onclick="login.submit();"> <?= @text('Login') ?> </a> </div> </div> <div class="clr"></div> <input type="submit" style="border: 0; padding: 0; margin: 0; width: 0px; height: 0px;" value="<?= @text('Login') ?>" /> </form>
/** * Load a template helper * * This functions accepts a partial identifier, in the form of helper.function. If a partial * identifier is passed a full identifier will be created using the template identifier. * * @param string Name of the helper, dot separated including the helper function to call * @param mixed Parameters to be passed to the helper * @return string Helper output */ public function loadHelper($identifier, $params = array()) { //Get the function to call based on the $identifier $parts = explode('.', $identifier); $function = array_pop($parts); //Create the complete identifier if a partial identifier was passed if (is_string($identifier) && count($parts) == 1) { $identifier = clone $this->getIdentifier(); $identifier->path = array('template', 'helper'); $identifier->name = $parts[0]; } else { $identifier = implode('.', $parts); } //Create the template helper $helper = KTemplateHelper::factory($identifier); //Call the helper function if (!is_callable(array($helper, $function))) { throw new KTemplateHelperException(get_class($helper) . '::' . $function . ' not supported.'); } return $helper->{$function}($params); }