public static function setModelFieldList($data, $type = "AR", $class = "") { if (count(FormsController::$modelFieldList) == 0) { if ($type == "AR") { FormsController::$modelFieldList = $data; $rel = isset($data['Relations']) ? $data['Relations'] : array(); FormsController::$relFieldList = array_merge(array('' => '-- None --', '---' => '---', 'currentModel' => 'Current Model', '--' => '---'), $rel); } else { foreach ($data as $name => $field) { FormsController::$modelFieldList[$name] = $name; } unset(FormsController::$modelFieldList['type']); } } }
public static function showFormLB($formId, $contactId = null) { $db = Zend_Registry::get('db'); $themePath = NET_PATH . "widgets/"; $host = ViewController::$host; $view = new Zend_View(); $view->addScriptPath($themePath . "templates/"); //$formList = $db ->fetchAll("SELECT * FROM contact_forms WHERE id = ?", array($formId)); $form['contactForm'] = FormsController::_contactForm($formId, $contactId); //$form['title'] = ucwords($formId[0]['formName']) . ' Form'; $view->assign($form); $scriptName = "modForms.phtml"; $partialOutput = $view->render($scriptName); return $partialOutput; }
/** *Preparing contents from database to be rendered *with replacing of the template variables * *@author NT * */ public static function _templatePrepare($outputDB, $content = null, $lang = null, $pageInfo = null) { $db = Zend_Registry::get('db'); $title = Zend_Registry::get('pageTitle'); $langCode = self::$lang; $langCode = Zend_Registry::get('langCode'); if ($langCode == "") { //OVO MORA DA SE SKLONI!!!!! $langCode = "sr"; } $replaceThis = preg_match_all('/[{].+[}]/', $outputDB, $matches); foreach ($matches[0] as $part) { $parts = explode(":", $part); $Tvars[] = $parts; } if (count(@$Tvars)) { foreach ($Tvars as $Tvarss) { $i = 0; foreach ($Tvarss as $TV) { $module = trim($TV, "{}"); $build2[] = $module; $i++; } $build[] = $build2; $build2 = array(); } } //print_r($build); //print_r($matches); $count = 0; $cHI = 0; if (count(@$build)) { foreach ($build as $build_) { @($pattern = $matches[$count]); //TITLE OF THE PAGE //if (@preg_match("/{title}/", "{" . $build_[0] . "}" )) { if (@strstr("{" . $build_[0] . "}", "{title}")) { $output = $title; $outputDB = str_replace('{title}', $output, $outputDB); } //PAGE INFO HANDLE //if (@preg_match("/{searchform}/", "{" . $build_[0] . "}" )) { if (@strstr("{" . $build_[0] . "}", "{pageinfo}")) { $output = ViewController::pageInfo($pageInfo); $outputDB = str_replace('{pageinfo}', $output, $outputDB); } if (@strstr("{" . $build_[0] . "}", "{adminurl}")) { $outputDB = str_replace('{adminurl}', '<a href="' . NetActionController::$hostRW . NetActionController::$adminUrl . '" target="_blank">Admin (FF!/Safari/Chrome)</a>', $outputDB); } //SEARCH HANDLE //if (@preg_match("/{searchform}/", "{" . $build_[0] . "}" )) { if (@strstr("{" . $build_[0] . "}", "{searchform}")) { $output = SearchController::showSearchForm(); $outputDB = str_replace('{searchform}', $output, $outputDB); } //HTML PART HANDLE if (@strstr("{" . $build_[0], "{html")) { //$codeAll = $build_[1] . ":" . $build_[2]; //$countBuild = count($build_); $codeA = ""; foreach ($build_ as $countedB) { $codeA .= $countedB . ":"; } $codeA = ltrim($codeA, "html:"); $codeA = rtrim($codeA, ":"); $output = htmlspecialchars_decode($codeA); $output = str_replace('<br />', "", $output); $output = str_replace('<br>', "\n", $output); //$output = '<script type="text/javascript">document.write(' ."\n" . $output . ');</script>'; $outputDB = str_replace('{html:' . $codeA . '}', $output, $outputDB); //$outputDB = str_replace('{html' , $output, $outputDB); } //xHTML PART HANDLE - if this code block is to be xhtml purified if (@strstr("{" . $build_[0], "{x-html")) { $codeA = ""; foreach ($build_ as $countedB) { $codeA .= $countedB . ":"; } $codeA = ltrim($codeA, "x-html:"); $codeA = rtrim($codeA, ":"); $output = htmlspecialchars_decode($codeA); $output = str_replace('<br />', "", $output); $output = str_replace('<br>', "\n", $output); //$output = '<script type="text/javascript">document.write(' ."\n" . $output . ');</script>'; $outputDB = str_replace('{x-html:' . $codeA . '}', $output, $outputDB); //$outputDB = str_replace('{html' , $output, $outputDB); } //LANGUAGE chooser //if (@preg_match("/{language:flags}/", "{" . $build_[0] . ":flags}" )) { if (@strstr("{" . $build_[0] . ":flags}", "{language:flags}")) { $langsEnabled = NetActionController::getStaticEnabledLanguages(); /* $langQ = $db->fetchAll("SELECT * FROM languages WHERE enabled = '1'"); foreach ($langQ as $lang) { $langsEnabled[] = $lang['code']; } */ $output = ViewController::showLanguageChooser($langsEnabled); $outputDB = str_replace('{language:flags}', $output, $outputDB); } //MENU HANDLE //if (@preg_match("/menu:display/", "{" . $build_[0] . ":" . $build_[1])) { if (@strstr($build_[0] . ":" . $build_[1], "menu:display")) { $menuId = trim($build_[2], '""'); @($orientation = $build_[3]); //if ($orientation =! "slide") { //$menuQ = $db->fetchAll("SELECT *, url_en as url,name_en as name,description_en as description FROM menu_items WHERE menu_id = ?", array($menuId)); //} else { $menuQ = $db->fetchAll("SELECT *, menu_items.check_access as chkAccess, menu_items.content_id as cid, url_{$langCode} as url, name_{$langCode} as name, description_{$langCode} as description FROM menu_items LEFT JOIN pages_{$langCode} ON menu_items.content_id = pages_{$langCode}.id WHERE menu_id = ? AND pages_{$langCode}.published = '1' ORDER BY weight ASC", array($menuId)); //} //print_r($menuQ ); if (!empty($menuQ)) { $output = ViewController::displayMenu($menuQ, $orientation); if ($orientation == "") { $orient = ""; } elseif ($orientation == "vertical") { $orient = ":vertical"; } elseif ($orientation == "tree") { $orient = ":tree"; } elseif ($orientation == "slide") { $orient = ":slide"; } $outputDB = str_replace('{menu:display:' . $build_[2] . @$orient . '}', $output, $outputDB); } else { $outputDB = str_replace('{menu:display:' . $build_[2] . @$orient . '}', '<b style="color:red;">{menu:' . $build_[2] . '}Doesn\'t exist or it is empty!</b>', $outputDB); } } //CATEGORIES //if (@preg_match("/category:display/", "{" . $build_[0] . ":" . $build_[1])) { if (@strstr($build_[0] . ":" . $build_[1], "category:display")) { $catId = trim($build_[2], '""'); @($orientation = $build_[3]); $catQ = $db->fetchAll("SELECT id, title, alias, category, image, description, check_access FROM pages_{$langCode} WHERE category = ? AND pages_{$langCode}.published = '1'", array($catId)); //$catQ = $db->fetchAll("SELECT id, title, alias, category, image, description, check_access FROM pages_$langCode WHERE category = ? AND pages_$langCode.published = '1'", array($catId)); //$catQ = array(); $catItemsArray2 = $db->fetchAll("SELECT DISTINCT *, pages_{$langCode}.id as id, pages_{$langCode}.title as title, pages_{$langCode}.alias as alias, pages_{$langCode}.category as category, pages_{$langCode}.image, pages_{$langCode}.description, pages_{$langCode}.check_access as check_access FROM category_items LEFT JOIN pages_{$langCode} ON pages_{$langCode}.id = category_items.content_id WHERE category_items.category_id = ? AND pages_{$langCode}.published = '1' GROUP BY pages_{$langCode}.id DESC ", array($catId)); $catQ = array_merge($catQ, $catItemsArray2); //$catQ = $catQ + $catItemsArray2; //print_r($menuQ ); if (!empty($catQ)) { $output = ViewController::displayCategory($catQ, $orientation); if ($orientation == "") { $orient = ""; } elseif ($orientation == "oldest") { $orient = ":oldest"; } elseif ($orientation == "latest") { $orient = ":latest"; } elseif ($orientation == "desc") { $orient = ":desc"; } $outputDB = str_replace('{category:display:' . $build_[2] . @$orient . '}', $output, $outputDB); } else { $outputDB = str_replace('{category:display:' . $build_[2] . @$orient . '}', '<b style="color:red;">{category:' . $build_[2] . '}Doesn\'t exist or it is empty!</b>', $outputDB); } } //SLIDE cu3er if (@strstr("{" . $build_[0] . "}", "{cu3er}")) { $output = ViewController::slides(); $outputDB = str_replace('{cu3er}', $output, $outputDB); } //DISPLAY IMAGES //if (@preg_match("/images:display/", "{" . $build_[0] . ":" . $build_[1])) { if (@strstr($build_[0] . ":" . $build_[1], "images:display")) { $folder = trim($build_[2], '""'); $folder = trim($folder, "''"); @($image = trim($build_[3], "''")); //$menuQ = $db->fetchAll("SELECT *, url_en as url,name_en as name,description_en as description FROM menu_items WHERE menu_id = ?", array($menuId)); //print_r($menuQ ); if (!empty($folder)) { if (empty($image)) { $output = ViewController::displayImages($folder); $imageOut = ""; } else { $output = ViewController::displayImage($folder, $image); $imageOut = ":'" . $image . "'"; } $outputDB = str_replace('{images:display:' . $build_[2] . $imageOut . '}', $output, $outputDB); //$outputDB = str_replace('{images:display:' . $build_[2] . '}', "AAAAA", $outputDB); } else { $outputDB = str_replace('{images:display:' . $build_[2] . $imageOut . '}', '<b style="color:red;">{images:' . $build_[2] . '}Doesn\'t exist or it is empty!</b>', $outputDB); } } //EXTERN Joomla!! if (@preg_match("/extern:joomla/", "{" . $build_[0] . ":" . $build_[1])) { $folder = trim($build_[2], '""'); $folder = trim($folder, "''"); $type = trim($build_[2], '""'); //print_r($menuQ ); if (!empty($type)) { $output = ViewController::displayExternJoomla($type); $imageOut = ""; $outputDB = str_replace('{extern:joomla:' . $build_[2] . $imageOut . '}', $output, $outputDB); } else { $outputDB = str_replace('{extern:joomla:' . $build_[2] . $imageOut . '}', '<b style="color:red;">{images:' . $build_[2] . '}Doesn\'t exist or it is empty!</b>', $outputDB); } } //MODULE 'FORM' if (@preg_match("/module:forms/", "{" . $build_[0] . ":" . $build_[1])) { $contactFormName = trim($build_[2], "''"); $contactFormId = $db->fetchAll("SELECT *, mod_forms.name as formName FROM mod_forms LEFT JOIN mod_forms_fields ON mod_forms.id = mod_forms_fields.form_id WHERE enabled = '1' AND mod_forms.name = ?", array($contactFormName)); //print_r($contactFormId); if (!empty($contactFormId)) { $formId = $contactFormId; $output = FormsController::showForm($formId); $outputDB = str_replace('{module:forms:' . $build_[2] . '}', $output, $outputDB); } else { $outputDB = str_replace('{module:forms:' . $build_[2] . '}', '<b style="color:red;">{module:forms:' . $build_[2] . '}Doesn\'t exist!</b>', $outputDB); } } $outputString = ""; $count++; } } else { //$output = ViewController::setDefaultHeaderImage(); //$outputDB .= $output; } $outputDB = str_replace('{content}', $content, $outputDB); return $outputDB; }
/** * @author Ruffy * @param int $business_id * @return mixed * @description Adds an option to display the broadcast page by Business */ public function getBusiness($business_id = 0) { $data = json_decode(file_get_contents(public_path() . '/json/' . $business_id . '.json')); $arr = explode("-", $data->display); if ($arr[0]) { $template_type = 'ads-' . $arr[1]; } else { $template_type = 'noads-' . $arr[1]; } if ($data->ad_type == 'image') { $ad_src = array(); $res = AdImages::getAllImagesByBusinessId($business_id); foreach ($res as $count => $img) { $ad_src[] = $img->path; } /* $ad_directory = public_path() . '/ads/' . $business_id; if (file_exists($ad_directory)) { foreach(glob($ad_directory . '/*.*') as $filename){ $ad_src[] = 'ads/' . $business_id . '/' . basename($filename); } } */ } else { $ad_src = $data->ad_video; } $business_name = Business::name($business_id); $open_time = str_pad(Business::openHour($business_id), 2, 0, STR_PAD_LEFT) . ':' . str_pad(Business::openMinute($business_id), 2, 0, STR_PAD_LEFT) . ' ' . Business::openAMPM($business_id); $close_time = str_pad(Business::closeHour($business_id), 2, 0, STR_PAD_LEFT) . ':' . str_pad(Business::closeMinute($business_id), 2, 0, STR_PAD_LEFT) . ' ' . Business::closeAMPM($business_id); $first_service = Service::getFirstServiceOfBusiness($business_id); $allow_remote = QueueSettings::allowRemote($first_service->service_id); // Update Contact Form with Custom Fields if applicable $custom_fields = ''; $forms = new FormsController(); $fields = $forms->getFields($business_id); foreach ($fields as $form_id => $field_data) { if ($field_data['field_type'] == 'Text Field') { $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div> <div class="col-md-9"><input type="text" class="form-control custom-field" id="forms_' . $form_id . '" /></div>'; } elseif ($field_data['field_type'] == 'Radio') { $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div> <div class="col-md-9"><label class="radio-inline"><input type="radio" name="forms_' . $form_id . '" value="' . $field_data['value_a'] . '" >' . $field_data['value_a'] . '</label><label class="radio-inline"><input type="radio" name="forms_' . $form_id . '" value="' . $field_data['value_b'] . '">' . $field_data['value_b'] . '</label></div>'; } elseif ($field_data['field_type'] == 'Checkbox') { $custom_fields .= '<div class="col-md-offset-3 col-md-9 mb10 mt10"><label class="checkbox-inline"><input type="checkbox" id="forms_' . $form_id . '" value="1"/>' . $field_data['label'] . '</label></div>'; } elseif ($field_data['field_type'] == 'Dropdown') { $select_options = ''; $select_options .= '<option value="0">- Select -</option>'; foreach ($field_data['options'] as $count => $val) { $select_options .= '<option value="' . $val . '">' . $val . '</option>'; } $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div> <div class="col-md-9"><select class="form-control custom-dropdown" id="forms_' . $form_id . '"/>' . $select_options . '</select></div>'; } } $ticker_message = array(); if (isset($data->ticker_message)) { if ($data->ticker_message != '') { array_push($ticker_message, $data->ticker_message); } } if (isset($data->ticker_message2)) { if ($data->ticker_message2 != '') { array_push($ticker_message, $data->ticker_message2); } } if (isset($data->ticker_message3)) { if ($data->ticker_message3 != '') { array_push($ticker_message, $data->ticker_message3); } } if (isset($data->ticker_message4)) { if ($data->ticker_message4 != '') { array_push($ticker_message, $data->ticker_message4); } } if (isset($data->ticker_message5)) { if ($data->ticker_message5 != '') { array_push($ticker_message, $data->ticker_message5); } } if (Auth::check()) { $user = User::getUserByUserId(Auth::user()->user_id); // business owners have different broadcast screens for display if (UserBusiness::getBusinessIdByOwner(Auth::user()->user_id) == $business_id) { if ($arr[0] == 2 || $arr[0] == 3) { $ad_src = $data->tv_channel; // check if TV is on if ($arr[0] == 3) { $template_type = 'ads-' . $arr[1] . '-2'; } $broadcast_template = 'broadcast.default.internet-tv-master'; } else { $broadcast_template = 'broadcast.default.business-master'; } } else { $broadcast_template = 'broadcast.default.public-master'; } } else { $user = []; $broadcast_template = 'broadcast.default.public-master'; } $date = mktime(0, 0, 0, date('m'), date('d'), date('Y')); return View::make($broadcast_template)->with('carousel_interval', isset($data->carousel_delay) ? (int) $data->carousel_delay : 5000)->with('custom_fields', $custom_fields)->with('ad_type', $data->ad_type)->with('ad_src', $ad_src)->with('box_num', $arr[1])->with('template_type', $template_type)->with('broadcast_type', $data->display)->with('open_time', $open_time)->with('close_time', $close_time)->with('local_address', Business::localAddress($business_id))->with('business_id', $business_id)->with('business_name', $business_name)->with('lines_in_queue', Analytics::getBusinessRemainingCount($business_id))->with('estimate_serving_time', Analytics::getAverageTimeServedByBusinessId($business_id, 'string', $date, $date))->with('first_service', Service::getFirstServiceOfBusiness($business_id))->with('allow_remote', $allow_remote)->with('ticker_message', $ticker_message)->with('user', $user); }