Skip to content

Instantly share code, notes, and snippets.

@gebv
Created May 14, 2015 08:55
Show Gist options
  • Save gebv/0e464be788556b89f06f to your computer and use it in GitHub Desktop.
Save gebv/0e464be788556b89f06f to your computer and use it in GitHub Desktop.
<?php
/**
* Widgets Tag Processor (sample)
*
*/
class SampleWidget extends TagProcessor
{
/**
* Returns a link for editing.
*
* @param array $params Params.
*
* @return string
*/
protected function ItemEditLink(array $params)
{
$object = $this->getObject($params);
/* @var $object kDBList */
$a_path = $this->App->getOptoins($this->Prefix, 'TemplatePath');
$edit_template = $a_path . '/' . $this->App->getOptoins($this->Prefix, 'TemplatePrefix') . 'edit';
$url_params = array(
'm_opener' => 'd',
$this->Prefix . '_event' => 'OnEdit',
$this->Prefix . '_id' => $object->GetID(),
'pass' => 'all,' . $this->Prefix,
'no_pass_through' => 1,
);
return $this->App->UrlFor($edit_template, '', $url_params);
}
/**
* Creates link to an item including only it's id.
*
* @param array $params Params.
*
* @return string
*/
protected function ItemLink($params)
{
$object = $this->getObject($params);
/* @var $object kDBItem */
$params['pass'] = 'm,' . $this->Prefix;
$params[$object->Prefix . '_id'] = $object->GetID();
$params[$object->Prefix . '_filename'] = $object->GetDBField('Title');
return $this->App->UrlFor('m', 'Link', $params);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment