Example #1
0
 public function view($id)
 {
     //validates plugin id to check if it exists
     $pluginInfo = $this->model->valPlugin($id);
     $pluginListBuilder = new PluginListBuilder();
     $this->view->html = $pluginListBuilder->renderBody($id);
     $this->view->pluginId = $id;
     $this->view->title = $pluginInfo['name'] . ' plugin';
     $this->view->render('header');
     $this->view->render('topnav');
     $this->view->render('menu');
     $this->view->render('plugins/main');
     $this->view->render('footer');
 }
 public function formBody($plugstrucid, $fieldsetId, $id = NULL)
 {
     if (isset($id)) {
         $current_q = 'SELECT * FROM cms_content 
                       WHERE
                       id = "' . $id . '"';
         $current_r = mysql_query($current_q);
         $current = mysql_fetch_array($current_r);
     }
     $pstruc_q = 'SELECT * FROM cms_plugin_structure 
                  WHERE 
                  id = "' . $plugstrucid . '"';
     $pstruc_r = mysql_query($pstruc_q);
     $pstruc = mysql_fetch_array($pstruc_r);
     $records_q = 'SELECT * FROM cms_records 
     			  WHERE 
     			  fieldsetid = "' . $fieldsetId . '" 
     			  ORDER BY sortorder ASC';
     $records_r = mysql_query($records_q);
     $x = 0;
     $znum = 0;
     $formBody = '';
     while ($records = mysql_fetch_array($records_r)) {
         $x++;
         $znum++;
         $recordOptions = Apps::get_field_options($records['options'], $znum);
         $elementNameId = $pstruc['db_name'] . '_' . $records['db_name'];
         $formBody .= "<div class=\"rowElem" . ($x == 1 ? ' noborder' : '') . "\">\n";
         $formBody .= "<label>" . $records['name'] . ($recordOptions['record_required'] == 'true' ? '* ' : '') . ": " . (!empty($records['helper']) ? '<a onclick="$.jGrowl(\'' . $records['helper'] . '\');">&nbsp;&nbsp;<i class="fa fa-question-circle fa-1x"></i></a>' : '') . "</label>\n";
         $formBody .= "<div class=\"formRight\">\n";
         switch ($records['type']) {
             case "text":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" " . "type=\"text\" " . "name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . ($recordOptions['record_email'] == 'true' ? ',custom[email]' : '') . "]\" " . "style=\"" . $recordOptions['record_styles'] . "\"/>\n";
                 break;
             case "number":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" " . "type=\"text\" name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\" " . "style=\"" . $recordOptions['record_styles'] . "\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . ",custom[number]]\" " . "style=\"" . $recordOptions['record_styles'] . "\"/>";
                 break;
             case "email":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" " . "type=\"text\" name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\" " . "style=\"" . $recordOptions['record_styles'] . "\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . ",custom[email]]\" " . "style=\"" . $recordOptions['record_styles'] . "\"/>\n";
                 break;
             case "html":
                 $formBody .= "<textarea " . "class=\"tinymce validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" " . "name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\">" . stripslashes($current[$records['db_name']]) . "</textarea>\n";
                 break;
             case "textarea":
                 $formBody .= "<textarea " . "name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\" " . "rows=\"10\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" " . "style=\"" . $recordOptions['record_styles'] . "\">" . $current[$records['db_name']] . "</textarea>\n";
                 break;
             case "select":
             case "multiselect":
                 $formBody .= "<select name=\"" . $elementNameId . ($records['type'] == 'multiselect' ? '[]' : '') . "\" " . "id=\"" . $elementNameId . ($records['type'] == 'multiselect' ? '[]' : '') . "\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" ";
                 switch ($records['type']) {
                     case 'multiselect':
                         $formBody .= "multiple=\"multiple\" ";
                         break;
                 }
                 $formBody .= "style=\"" . $recordOptions['record_styles'] . "\">";
                 for ($d = 0; $d < count($recordOptions['record_select_vals']); $d++) {
                     // echo $recordOptions['record_select_vals'][$d] . '\b/',$current[$records['db_name']];
                     $formBody .= "\n<option value=\"" . $recordOptions['record_select_vals'][$d] . "\"" . ($recordOptions['record_select_vals'][$d] == $current[$records['db_name']] ? ' selected' : '') . ">" . $recordOptions['record_select_vals'][$d] . "</option>";
                 }
                 $formBody .= "\n</select>\n";
                 break;
             case "yesno":
                 $formBody .= "<input type=\"radio\" id=\"" . $elementNameId . "1\" name=\"" . $elementNameId . "\" checked=\"checked\" value=\"yes\" />\n" . "<label for=\"" . $elementNameId . "1\">Yes</label>\n";
                 $formBody .= "<input type=\"radio\" id=\"" . $elementNameId . "2\" name=\"" . $elementNameId . "\" value=\"no\"/>\n" . "<label for=\"" . $elementNameId . "2\">No</label>\n";
                 break;
             case "checkboxes":
                 $checkArr = explode(',', $current[$records['db_name']]);
                 for ($d = 0; $d < count($recordOptions['record_select_vals']); $d++) {
                     $formBody .= "<input type=\"checkbox\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" " . "id=\"" . $elementNameId . $d . "\" name=\"" . $elementNameId . "[]\" " . (preg_match('/\\b' . $recordOptions['record_select_vals'][$d] . '\\b/', $current[$records['db_name']]) ? 'checked ' : '') . "value=\"" . $recordOptions['record_select_vals'][$d] . "\" />\n" . "<label for=\"" . $elementNameId . $d . "\">" . $recordOptions['record_select_vals'][$d] . "</label>\n";
                 }
                 break;
             case "radio":
                 for ($d = 0; $d < count($recordOptions['record_select_vals']); $d++) {
                     $formBody .= "<input type=\"radio\" class=\"validate[" . ($recordOptions['record_select_vals'][$d] == 'true' ? 'required' : 'optional') . "]\" id=\"" . $elementNameId . $d . "\" name=\"" . $elementNameId . "\" " . (preg_match('/\\b' . $recordOptions['record_select_vals'][$d] . '\\b/', $current[$records['db_name']]) ? 'checked' : '') . " value=\"" . $recordOptions['record_select_vals'][$d] . "\" />\n" . "<label for=\"" . $elementNameId . $d . "\">" . $recordOptions['record_select_vals'][$d] . "</label>\n";
                 }
                 break;
             case "photo":
             case "multiphoto":
                 $formBody .= !empty($current[$records['db_name']]) ? "<div class=\"recordImg\">\n" . "<a title=\"Delete '" . $current[$records['db_name']] . "'\" data-id=\"" . $id . "\" data-recordname=\"" . $records['db_name'] . "\" data-filename=\"" . strtolower($current[$records['db_name']]) . "\"></a>\n" . "<img src=\"" . _SITEROOT_ . "uploads/" . $id . "/" . $records['db_name'] . "/300xauto_" . strtolower($current[$records['db_name']]) . "\" />\n" . "</div>\n" : '';
                 $formBody .= "<input type=\"file\" class=\"validate[" . ($recordOptions['record_required'] == 'true' && empty($current[$records['db_name']]) ? 'required' : 'optional') . ",checkFileType[jpg|jpeg|gif|JPG|png|PNG|ico|bmp]] fileInput\" name=\"" . $elementNameId . ($records['db_name'] == "multiphoto" ? "[]" : "") . "\" " . ($records['db_name'] == "multiphoto" ? " mulitple=\"multiple\" " : "") . " id=\"" . $elementNameId . "[]\" />\n";
                 break;
             case "file":
                 $ext = strtolower(pathinfo($current[$records['db_name']], PATHINFO_EXTENSION));
                 $formBody .= !empty($current[$records['db_name']]) ? "<div class=\"recordFile\">\n" . "<a class=\"deleteRecordFile\" title=\"Delete '" . $current[$records['db_name']] . "'\" data-id=\"" . $id . "\" data-recordname=\"" . $records['db_name'] . "\" data-filename=\"" . $current[$records['db_name']] . "\"></a>\n" . "<a href=\"" . _EQROOT_ . "resources/uploads/" . $id . "/" . $records['db_name'] . "/" . $current[$records['db_name']] . "\" target=\"_blank\" class=\"documentIcon " . $ext . "\"></a>\n" . "</div>\n" : '';
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" type=\"file\" class=\"validate[" . ($recordOptions['record_required'] == 'true' && empty($current[$records['db_name']]) ? 'required' : 'optional') . ",checkFileType[pdf|doc|docx|xls|csv|rar|txt|avi|mov|flv|mp3|zip|wav|php|html|css|js|jar|bak|tar|sys|exe|iso]] " . "fileInput\" name=\"" . $elementNameId . "\" id=\"" . $elementNameId . "\" />\n";
                 break;
             case "date":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" type=\"text\" " . "class=\"datepicker validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" name=\"" . $elementNameId . "\" id=\"" . $elementNameId . "\" />\n";
                 break;
             case "color":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" type=\"text\" " . "class=\"colorpick validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" id=\"" . $elementNameId . "\" name=\"" . $elementNameId . "\" id=\"" . $elementNameId . "\"/>\n\n                                 <label for=\"" . $elementNameId . "\" class=\"pick\"></label>\n";
                 break;
             case "time":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" type=\"text\" class=\"timepicker validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" name=\"" . $elementNameId . "\" id=\"" . $elementNameId . "\" size=\"10\">\n" . "<span class=\"ml10\">use your mousewheel and keyboard</span>\n";
                 break;
             case "foreignkey":
                 $fcomStruc_q = 'SELECT * FROM cms_plugin_structure 
                 				WHERE 
                 				id = "' . $records['fkey'] . '"';
                 $fcomStruc_r = mysql_query($fcomStruc_q);
                 $fcomStruc = mysql_fetch_array($fcomStruc_r);
                 $fFieldset_q = 'SELECT * FROM cms_fieldsets 
                                 WHERE
                                 com_struc_id = "' . $records['fkey'] . '"';
                 $fFieldset_r = mysql_query($fFieldset_q);
                 $fkeyFieldset = mysql_fetch_array($fFieldset_r);
                 $fetchKeys_q = 'SELECT * FROM cms_content 
                 				WHERE 
                 				pluginid = "' . $fcomStruc['pluginid'] . '"
                 				AND recordset = "' . $fcomStruc['db_name'] . '"';
                 $fetchKeys_r = mysql_query($fetchKeys_q);
                 $fkeyOptions = explode(',', $recordOptions['record_fkeyoptions']);
                 if (count($fkeyOptions)) {
                     $fkeyOptions = PluginListBuilder::validateRecordViaFieldset($fkeyOptions, $fkeyFieldset['id']);
                 } else {
                     $fkeyOptions = array('id');
                 }
                 $fkeyValues = explode(',', $recordOptions['record_fkeyvalue']);
                 if (count($fkeyOptions)) {
                     $fkeyValues = PluginListBuilder::validateRecordViaFieldset($fkeyValues, $fkeyFieldset['id']);
                 } else {
                     $fkeyValues = array('id');
                 }
                 $formBody .= "<select " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" " . "name=\"" . $elementNameId . ($recordOptions['record_fkeytype'] == 'multiselect' ? '[]' : '') . "\" " . "id=\"" . $elementNameId . ($recordOptions['record_fkeytype'] == 'multiselect' ? '[]' : '') . "\" " . ($recordOptions['record_fkeytype'] == 'multiselect' ? 'multiple="multiple"' : '') . "style=\"" . $recordOptions['record_styles'] . "\">\n";
                 while ($fetchKey = mysql_fetch_array($fetchKeys_r)) {
                     $fkeyValue = !empty($fkeyValues) ? $fetchKey[$fkeyValues[0]] : $fetchKey['id'];
                     $formBody .= "\n<option " . (preg_match('/\\b' . $fkeyValue . '\\b/', $current[$records['db_name']]) ? ' selected' : '') . ' value="' . $fkeyValue . '">';
                     foreach ($fkeyOptions as $option) {
                         $formBody .= $fetchKey[$option];
                     }
                     $formBody .= "</option>";
                 }
                 $formBody .= "\n</select>\n";
                 break;
             case "custom_url":
                 $formBody .= "<input type=\"text\" disabled=\"disabled\" value=\"" . $current[$records['db_name']] . "\"/>\n";
                 break;
         }
         $formBody .= "</div>\n";
         $formBody .= "<div class=\"fix\"></div>\n";
         $formBody .= "</div>\n";
     }
     return $formBody;
 }
 function renderBody($pluginId)
 {
     return PluginListBuilder::buildPluginStrucTabs($pluginId) . PluginListBuilder::renderContainer($pluginId);
 }