Example #1
0
 public function render()
 {
     $name = $this->getName();
     $img = KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.img', '/32/' . $name . '.png');
     if ($img) {
         KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.css', '.toolbar .icon-32-' . $name . ' { background-image: url(' . $img . '); }');
     }
     $text = JText::_($this->_options['text']);
     $view = KRequest::get('get.view', 'cmd');
     $link = ' href="' . JRoute::_($this->getLink()) . '"';
     $html = array();
     // Sanitize the url since we can't trust the server var
     $url = KFactory::get('lib.koowa.filter.url')->sanitize($this->getLink());
     // Create the URI object
     $uri = KFactory::tmp('lib.koowa.http.uri', array('uri' => $url));
     $query = $uri->getQuery(1);
     $html[] = '<td class="button" id="' . $this->getId() . '">';
     $active = $view == KInflector::variablize(KInflector::pluralize($query['view'])) || $view == KInflector::variablize(KInflector::singularize($query['view']));
     $hide = !KInflector::isPlural($view);
     if ($active || $hide || !$this->modal) {
         $html[] = '<a class="toolbar inactive">';
     } else {
         $html[] = '<a' . $link . ' onclick="' . $this->getOnClick() . '" class="toolbar">';
     }
     $html[] = '<span class="' . $this->getClass() . '" title="' . $text . '">';
     $html[] = '</span>';
     $html[] = $text;
     if (!$active && !$hide || $this->modal) {
         $html[] = '</a>';
     } else {
         $html[] = '</a>';
     }
     $html[] = '</td>';
     return implode(PHP_EOL, $html);
 }
Example #2
0
 public function render()
 {
     $name = $this->getName();
     $img = KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.img', '/32/' . $name . '.png');
     if ($img) {
         KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.css', '.toolbar .icon-32-' . $name . ' { background-image: url(' . $img . '); }');
     }
     $text = JText::_($this->_options['text']);
     $options[] = JHTML::_('select.option', null, $text);
     $options[] = JHTML::_('select.option', 'kunena', JText::_('Kunena'));
     $options[] = JHTML::_('select.option', 'sample', JText::_('Sample Content'));
     // TEST: Uncomment this line to test the fireboard import option
     //$options[]	= JHTML::_('select.option', 'fireboard', JText::_('FireBoard') );
     //$options[]	= JHTML::_('select.option', 'test', JText::_('Test Unsupported') );
     $select = KTemplateAbstract::loadHelper('select.genericlist', $options, 'import', array('class' => 'inputbox', 'onchange' => $this->getOnChange(), 'style' => 'cursor:pointer;width:70px;'));
     $html[] = '<td class="button" id="' . $this->getId() . '">';
     $html[] = '<a class="toolbar hasTip" title="' . JText::_('Select what you want to import') . '" style="cursor:default;" >';
     $html[] = '<span class="' . $this->getClass() . '" title="' . $text . '">';
     $html[] = '</span>';
     $html[] = $select;
     $html[] = '</a>';
     $html[] = '</td>';
     return implode(PHP_EOL, $html);
 }
Example #3
0
 /**
  * Parse the template
  * 
  * This function implements a caching mechanism when reading the template. If
  * the tempplate cannot be found in the cache it will be filtered and stored in
  * the cache. Otherwise it will be loaded from the cache and returned directly.
  *
  * @return string	The filtered data
  */
 public function parse()
 {
     if (isset($this->_cache)) {
         $identifier = md5($this->_path);
         if (!($template = $this->_cache->get($identifier))) {
             $template = parent::parse();
             //Store the object in the cache
             $this->_cache->store($template, $identifier);
         }
         return $template;
     }
     return parent::parse();
 }
Example #4
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param  KObjectConfig $config An optional ObjectConfig object with configuration options
  */
 protected function _initialize(KObjectConfig $config)
 {
     $config->append(array('debug' => false, 'cache' => false, 'cache_path' => '', 'cache_reload' => true, 'template' => 'default', 'functions' => array('object' => array($this, 'getObject'), 'translate' => array($this->getObject('translator'), 'translate'), 'json' => 'json_encode', 'format' => 'sprintf', 'replace' => 'strtr')));
     parent::_initialize($config);
 }
Example #5
0
 /**
  * Render the template
  *
  * @param   array   $data     An associative array of data to be extracted in local template scope
  * @return string The rendered template source
  */
 public function render(array $data = array())
 {
     parent::render($data);
     if ($this->_source instanceof KTemplateEngineInterface) {
         $this->_source = $this->_source->render($data);
         $this->_source = $this->filter();
     }
     return $this->_source;
 }
Example #6
0
 /**
  * Parse the template
  *
  * This function implements a caching mechanism when reading the template. If the template cannot be found in the
  * cache it will be filtered and stored in the cache. Otherwise it will be loaded from the cache and returned
  * directly.
  *
  * @param string The template content to parse
  * @return void
  */
 protected function _parse(&$content)
 {
     if (isset($this->_cache)) {
         $identifier = md5($this->getPath());
         if (!$this->_cache->get($identifier)) {
             parent::_parse($content);
             //Store the object in the cache
             $this->_cache->store($content, $identifier);
         } else {
             $content = $this->_cache->get($identifier);
         }
     } else {
         parent::_parse($content);
     }
 }
Example #7
0
 /**
  * Get a filter by identifier
  *
  * @return KTemplateFilterInterface
  */
 public function getFilter($filter)
 {
     //Create the complete identifier if a partial identifier was passed
     if (is_string($filter) && strpos($filter, '.') === false) {
         if (!isset($this->_filters[$filter])) {
             $identifier = clone $this->getIdentifier();
             $identifier->path = array('template', 'filter');
             $identifier->name = $filter;
             register_default(array('identifier' => $identifier, 'prefix' => $this));
             $filter = $identifier;
         }
     }
     return parent::getFilter($filter);
 }
Example #8
0
    /**
     * function description
     *
     * @author 		Stian Didriksen <*****@*****.**>
     * @return 		returns an image nested in an anchor element.
     */
    public function required($enable, $id, $imgY = 'enable.png', $imgX = 'disable.png')
    {
        //Load koowa javascript
        KTemplateAbstract::loadHelper('script', KRequest::root() . '/media/plg_koowa/js/koowa.js');
        $img = $enable ? $imgY : $imgX;
        $alt = $enable ? JText::_('Required') : JText::_('Optional');
        $text = $enable ? JText::_('Make item optional') : JText::_('Require Item');
        $action = $enable ? 'optional' : 'required';
        $href = '
		<a href="#" onclick="Koowa.Form.addField(\'' . $action . '\', \'cb' . $id . '\');Koowa.Form.addField(\'action\', \'' . $action . '\');Koowa.Form.submit(\'post\')" title="' . $text . '">
		<img src="' . JURI::root() . 'media/com_ninja/images/16/' . $img . '" border="0" alt="' . $alt . '" />
		</a>';
        return $href;
    }
Example #9
0
 public function img($src)
 {
     return KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.img', $src);
 }
Example #10
0
 /**
  * Remove rules 
  * 
  * @param $rules array	Associative array of rule class names
  */
 public static function delRules(array $rules = array())
 {
     self::$_rules = array_diff_assoc(self::$_rules, array_flip($rules));
 }
Example #11
0
    public function imagesgeneric($path, $name, $attribs = null, $selected = NULL, $idtag = false, $translate = false)
    {
        $images = KFactory::get('admin::com.ninja.model.images')->folder($path);
        $options = $images->getList();
        $img = $images->getImages();
        if (!$idtag) {
            $idtag = $name;
        }
        //die('<pre>'.var_export($img, true).'</pre>');
        $document = Kfactory::get('lib.joomla.document');
        $document->addScriptDeclaration('var ' . $idtag . 'Images = new Asset.images(' . json_encode((array) $img) . ', {
    onComplete: function(){
    	$(\'rank_image_preview\').empty(); ' . $idtag . 'Images[$(\'' . $idtag . '\').selectedIndex].clone().injectInside(\'rank_image_preview\');
    }
});');
        $attr = array('onchange' => '$(\'rank_image_preview\').empty(); ' . $idtag . 'Images[this.selectedIndex].clone().injectInside(\'rank_image_preview\')', 'class' => 'value', 'style' => 'display: block;');
        $document->addStyleDeclaration('.group.images {text-align: center; padding-right: 1px !important;
		padding-bottom: 1px !important;}
		.group.images select { width:100%; min-width: 60px; margin-top: 2px!important ; }');
        ob_start();
        ?>
		<div class="group images">
			
			
			<div id="rank_image_preview"><img src="<?php 
        echo KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.image', '/16/spinner.gif');
        ?>
" /></div>
			
			<?php 
        echo JHTML::_('genericlist', $options, $name, $attr, 'value', 'text', $selected);
        ?>
		</div>
		
	<?php 
        return ob_get_clean();
    }