예제 #1
0
파일: list.php 프로젝트: fracting/cmc
 /**
  * Create an array with mailchimps merge fields
  *
  * @param   string  $listId  - the list id
  *
  * @return array|bool
  */
 public static function getMergeFields($listId)
 {
     $api = new cmcHelperChimp();
     $fields = $api->listMergeVars($listId);
     $key = 'tag';
     $val = 'name';
     $options = false;
     if ($fields) {
         foreach ($fields as $field) {
             $choices = '';
             if (isset($field['choices'])) {
                 foreach ($field['choices'] as $c) {
                     $choices .= $c . '##';
                 }
                 $choices = substr($choices, 0, -2);
             }
             $req = $field['req'] ? 1 : 0;
             if ($req) {
                 $options[] = array($key => $field[$key] . ';' . $field['field_type'] . ';' . $field['name'] . ';' . $req . ';' . $choices, $val => $field[$val] . "*");
             } else {
                 $options[] = array($key => $field[$key] . ';' . $field['field_type'] . ';' . $field['name'] . ';' . $req . ';' . $choices, $val => $field[$val]);
             }
         }
     }
     return $options;
 }
예제 #2
0
파일: cmc.php 프로젝트: fracting/cmc
 /**
  * Loads the possible lists
  *
  * @return  mixed
  */
 public function loadFields()
 {
     $plugin = GetCmcTab::getPlugin();
     $listid = $plugin->params->get('listid', "");
     if (empty($listid)) {
         $content = '<div style="float:left;">' . JText::_('PLG_CMCCB_NO_FIELDS') . '</div>';
         return $content;
     }
     $api = new cmcHelperChimp();
     $fields = $api->listMergeVars($listid);
     $key = 'tag';
     $val = 'name';
     $options = false;
     if ($fields) {
         foreach ($fields as $field) {
             $choices = '';
             if (isset($field['choices'])) {
                 foreach ($field['choices'] as $c) {
                     $choices .= $c . '##';
                 }
                 $choices = substr($choices, 0, -2);
             }
             $req = $field['req'] ? 1 : 0;
             if ($field[$key] == 'EMAIL') {
                 if (isset($this->value) && !is_array($this->value)) {
                     $oldValue = $this->value;
                     $this->value = array();
                     $this->value[] = $oldValue;
                 }
                 $this->value[] = $field[$key] . ';' . $field['field_type'] . ';' . $field['name'] . ';' . $req . ';' . $choices;
             }
             if ($req) {
                 $options[] = array($key => $field[$key] . ';' . $field['field_type'] . ';' . $field['name'] . ';' . $req . ';' . $choices, $val => $field[$val] . "*");
             } else {
                 $options[] = array($key => $field[$key] . ';' . $field['field_type'] . ';' . $field['name'] . ';' . $req . ';' . $choices, $val => $field[$val]);
             }
         }
     }
     $attribs = 'multiple="multiple" size="8"';
     if ($options) {
         $content = "";
         $content .= JHtml::_('select.genericlist', $options, 'params[fields][]', $attribs, $key, $val, explode("|*|", $plugin->params->get('fields', "")));
     } else {
         $content = '<div style="float:left;">' . JText::_('PLG_CMCCB_NO_FIELDS') . '</div>';
     }
     return $content;
 }