Skip to content

Instantly share code, notes, and snippets.

View Swader's full-sized avatar
🏠
Buidling

Bruno Škvorc Swader

🏠
Buidling
View GitHub Profile
@Swader
Swader / staffhander1.php
Created September 12, 2012 09:55
Fetching roles for a user
// Use case for StaffHandler -> fetching roles for a user
/* This is only valid if you're doing it
* in the IntechController - and ONLY if you have previously
* defined $this->oRegistry as
* $this->oRegistry = $this->getRegistry();
*/
$oStaffHandler = new StaffHandler($this->oRegistry->get('StaffMapper'));
@Swader
Swader / ContactSearch.php
Created September 13, 2012 00:42
Contact Search Form
<?php
/**
* To build a search form, extend the BackendExtendedSearchForm
*
* Then, just add some more elements into it, like in the example below.
* When you add the elements, don't forget to render them in the view, and
* fetch them in the controller when the form is submitted.
*
* You can also write a form manually, but make sure you give it the class
@Swader
Swader / renderSearchForm.php
Created September 13, 2012 00:45
Rendering the Contacts Search Form
$this->searchForm->prepare();
echo $this->form()->openTag($this->searchForm);
echo $this->formRow($this->searchForm->get('validity'));
echo $this->formRow($this->searchForm->get('deleted'));
echo $this->formRow($this->searchForm->get('activated'));
echo $this->formInput($this->searchForm->get('search'));
echo $this->formRow($this->searchForm->get('submit'));
echo $this->form()->closeTag($this->searchForm);
@Swader
Swader / searchFunctionRules.php
Created September 13, 2012 00:37
Search Function Rules
/**
* Search methods MUST return an array with "rowCount" and "rowSet".
*
* Search methods build queries with provided params (filters) and
* options (display filters - page, items per page, etc. Search
* methods can then use the buildAndReturnMySQL method from the
* Database/Abstract, or they can return their own result set. The
* only important thing is that they always return a single array
* which contains "rowCount" and "rowSet" - this is very important for
* pagination.
@Swader
Swader / listContactsView.phtml
Created September 13, 2012 00:50
Contacts List View
<?php
$this->searchForm->prepare();
echo $this->form()->openTag($this->searchForm);
echo $this->formRow($this->searchForm->get('validity'));
echo $this->formRow($this->searchForm->get('deleted'));
echo $this->formRow($this->searchForm->get('activated'));
echo $this->formInput($this->searchForm->get('search'));
echo $this->formRow($this->searchForm->get('submit'));
echo $this->form()->closeTag($this->searchForm);
@Swader
Swader / listMethod-Contacts.php
Created September 13, 2012 00:47
Contacts List Function
public function listAction()
{
$oPagination = null;
$oSearchForm = new \Manager\Form\ContactSearch();
$oSearchForm->setAttribute('action', '/manager/contacts/list');
$oSearchForm->setData($_GET);
$bSearchMode = false;
// Display the search toolbar
@Swader
Swader / newComponentsSuggestion.php
Created September 13, 2012 14:50
User suggestion
<?php
/**
* Class User.php
*
* @category
* @package
* @license BSD License
* @version 0.01
* @since 2012-09-13
@Swader
Swader / ResultUsage.php
Created September 13, 2012 19:00
Usage example of the Result class
/**
* The Result class is the default return format of the APIs
*
* When you get a Result object (e.g. $r), the recommended way of checking
* whether or not it contains any values is like so:
*/
if ($r->count()) {
// Do something
}
@Swader
Swader / teamleaderReturn.php
Created September 17, 2012 15:50
MyRole Teamleader Return sample
// usersRoles ima polje teamLeaderId. To je accountId od nekog accounta.
// Ako ja uradim $user->getRoles(), i dobijem array MyRoles instanci, onda mogu ovo
// Slanje maila teamleaderu nekog korisnika :
$user->setId(10); // Neki korisnik čijem teamleaderu želimo poslati mail
foreach ($user->getRoles() as $myRole) {
if ($myRole->getRole()->getSlug() == 'author') {
$oTeamLeader = $myRole->getTeamLeader();
@Swader
Swader / postSocialIcons.php
Created September 19, 2012 09:31
For Drazhen with love <3
function post_social_icons() {
echo "<div class='pw-widget pw-size-large'>
   <a class='pw-button-googleplus'></a>
   <a class='pw-button-facebook'></a>
   <a class='pw-button-twitter'></a>
   <a class='pw-button-email'></a>
   <a class='pw-button-post'></a>
</div>
<script src='http://i.po.st/static/script/post-widget.js#publisherKey=71ivmi7rc1d5gkfogd4p' type='text/javascript'></script>
";