/** * Return HTML code for list <label> with checkbox, checked if subscribed, otherwise not * * @param array $list List data from MC * @return string HTML code */ public function listLabel($list) { $myLists = $this->getSubscribedLists(); //if is on database it gets checked $alreadyOnList = Mage::getSingleton('monkey/asyncsubscribers')->getCollection()->addFieldToFilter('lists', $list['id'])->addFieldToFilter('email', $this->_getEmail())->addFieldToFilter('processed', 0); if (count($alreadyOnList) > 0) { $myLists[] = $list['id']; } $checkbox = new Varien_Data_Form_Element_Checkbox(); $checkbox->setForm($this->getForm()); $checkbox->setHtmlId('list-' . $list['id']); $checkbox->setChecked((bool) (is_array($myLists) && in_array($list['id'], $myLists))); $checkbox->setTitle($checkbox->getChecked() ? $this->__('Click to unsubscribe from this list.') : $this->__('Click to subscribe to this list.')); $checkbox->setLabel($list['name']); $hname = $this->_htmlGroupName($list); $checkbox->setName($hname . '[subscribed]'); $checkbox->setValue($list['id']); $checkbox->setClass('monkey-list-subscriber'); return $checkbox->getLabelHtml() . $checkbox->getElementHtml(); }
/** * Return HTML code for list <label> with checkbox, checked if subscribed, otherwise not * * @param array $list List data from MC * @return string HTML code */ public function listLabel($list) { $myLists = $this->getSubscribedLists(); $checkbox = new Varien_Data_Form_Element_Checkbox(); $checkbox->setForm($this->getForm()); $checkbox->setHtmlId('list-' . $list['id']); $checkbox->setChecked((bool) (is_array($myLists) && in_array($list['id'], $myLists))); $checkbox->setTitle($checkbox->getChecked() ? $this->__('Click to unsubscribe from this list.') : $this->__('Click to subscribe to this list.')); $checkbox->setLabel($list['name']); $hname = $this->_htmlGroupName($list); $checkbox->setName($hname . '[subscribed]'); $checkbox->setValue($list['id']); $checkbox->setClass('monkey-list-subscriber'); return $checkbox->getLabelHtml() . $checkbox->getElementHtml(); }