function createController($name, $views) { global $path; $model = array('name' => $name); $template = APP_DIR . '/templates/controller.php'; $outputFile = $path . '/controllers/' . $name . 'Controller.php'; processTemplate($template, $model, $outputFile); echo "Creating controller {$name}\n"; if ($views) { $model['modelType'] = strtolower($name); $outputFile = $path . '/views/' . $model['modelType'] . '/list.php'; $template = APP_DIR . '/templates/list.php'; processTemplate($template, $model, $outputFile); $outputFile = $path . '/views/' . $model['modelType'] . '/edit.php'; $template = APP_DIR . '/templates/edit.php'; processTemplate($template, $model, $outputFile); $outputFile = $path . '/views/' . $model['modelType'] . '/view.php'; $template = APP_DIR . '/templates/view.php'; processTemplate($template, $model, $outputFile); } }
function processAdaptationset($Adapt, $periodProfiles, $periodBitstreamSwitching) { global $Adapt_arr, $Period_arr, $Adapt_urlbase, $adaptsetdepth, $Timeoffset, $perioddepth; //var_dump($Adapt); $dom = new DOMDocument('1.0'); $Adapt = $dom->importNode($Adapt, true); $Adapt = $dom->appendChild($Adapt); if ($Adapt->hasAttributes()) { //Get some attributes from Adaptationset $startWithSAP = $Adapt->getAttribute('startWithSAP'); $segmentAlignment = $Adapt->getAttribute('segmentAlignment'); $subsegmentAlignment = $Adapt->getAttribute('subsegmentAlignment'); $idadapt = $Adapt->getAttribute('id'); $scanType = $Adapt->getAttribute('scanType'); $mimeType = $Adapt->getAttribute('mimeType'); $codecs_AdaptSet = $Adapt->getAttribute('codecs'); // Get codecs, if present in Adaptation Set level if (empty($codecs_AdaptSet)) { $codecs_AdaptSet = 0; } $height_AdaptSet = $Adapt->getAttribute('height'); // Get height, if present in Adaptation Set level if (empty($height_AdaptSet)) { $height_AdaptSet = 0; } $width_AdaptSet = $Adapt->getAttribute('width'); // Get width, if present in Adaptation Set level if (empty($width_AdaptSet)) { $width_AdaptSet = 0; } $adapsetProfiles = $Adapt->getAttribute('profiles'); if ($adapsetProfiles === "") { $adapsetProfiles = $periodProfiles; } $bitstreamSwitching = $Adapt->getAttribute('bitstreamSwitching'); if ($bitstreamSwitching === "") { $bitstreamSwitching = $periodBitstreamSwitching; } $ContentProtection = $dom->getElementsByTagName("ContentProtection"); // Search for Content Protection element $Contentcomponent = $dom->getElementsByTagName("ContentComponent"); //Search for content component attribute $tr = $dom->childNodes->item(0)->nodeName; if ($Contentcomponent->length > 0) { //Check if content component exist $tempContentcomponent = $Contentcomponent->item(0); $contentType = $tempContentcomponent->getAttribute('contentType'); //Get content type } $Adapt_segmentbase = $Adapt->getElementsByTagName('SegmentBase'); //If segment base exist $Adapt_Timeoffset = 0; for ($i = 0; $i < $Adapt_segmentbase->length; $i++) { $base = $Adapt_segmentbase->item(0); $par = $base->parentNode; $name = $par->tagName; if ($name === 'AdaptationSet') { // Check if segment base is direct child of Adapatationset $basearray = processSegmentBase($base); //Process segmentbase if (!empty($basearray[0])) { $Adapt_Timeoffset = $basearray[0]; } //Get timeoffset if (!empty($basearray[1])) { $timescale = $basearray[1]; } //get timescale if (!empty($basearray[2])) { $indexRange_AdaptSet = $basearray[2]; //return array contains indexRange } } } if ($Adapt_Timeoffset === 0) { // if timeoffset exist then It has to replace the one existed on higher nodes $Adapt_Timeoffset = $Timeoffset; } $baseurl = $Adapt->getElementsByTagName("BaseURL"); // check and process baseurl node if it exist in adapationset level // $adaptsetdepth = array(); for ($i = 0; $i < $baseurl->length; $i++) { $base = $baseurl->item($i); $par = $base->parentNode; $name = $par->tagName; if ($name == 'AdaptationSet') { //Confirm Baseurl is direct child of adapationset $Adaptbase = $base->nodeValue; $adaptsetdepth[] = $Adaptbase; // Cumulative baseURL if (isAbsoluteURL($Adaptbase)) { // if baseurl is absolute URL, do not use the location of MPD as base URL: $dir = ""; $perioddepth[0] = ""; } } } $rep_seg_temp = array(); $segmenttemplate = $dom->getElementsByTagName("SegmentTemplate"); //Check if segment template exist in adaptationSet level if ($segmenttemplate->length > 0) { $Adapt_seg_temp_setflag = 0; for ($i = 0; $i < $segmenttemplate->length; $i++) { $seg_arr = array(); $seg = $segmenttemplate->item($i); $par = $seg->parentNode; $name = $par->tagName; if ($name == "AdaptationSet") { $Adapt_seg_temp = processTemplate($seg); $Adapt_seg_temp_setflag = 1; } else { if (!$Adapt_seg_temp_setflag) { $Adapt_seg_temp = null; } } } } else { $Adapt_seg_temp = 0; } //Check if AudioChannelConfiguration exists at AdapatationSet level. $audioChannelConfig_Adapt = $Adapt->getElementsByTagName("AudioChannelConfiguration"); if ($audioChannelConfig_Adapt->length > 0) { $audioCh_Adapt_item = $audioChannelConfig_Adapt->item(0); $parNode = $audioCh_Adapt_item->parentNode; $parName = $parNode->tagName; if ($parName == "AdaptationSet") { $audioCh_Adapt_value = $audioCh_Adapt_item->getAttribute('value'); } else { $audioCh_Adapt_value = 0; } } else { $audioCh_Adapt_value = 0; } $Representation = $dom->getElementsByTagName("Representation"); //Get representations node within Adapatationset if ($Representation->length > 0) { $rep_url = array(); $rep_seg_temp = array(); //Iterate on all representations within the given Adapatationset for ($i = 0; $i < $Representation->length; $i++) { $lastbase = array(); // Contains the latest BaseURL if exist $temprep = $Representation->item($i); $repbaseurl = $temprep->getElementsByTagName('BaseURL'); //check if representation contains BaseURL $Rep_segmentbase = $temprep->getElementsByTagName('SegmentBase'); //Check if segment Base exist if ($Rep_segmentbase->length > 0) { $base = $Rep_segmentbase->item(0); $segarray[] = processSegmentBase($base); // Process segment base if (!empty($segarray[$i][0])) { $Rep_Timeoffset[] = $segarray[$i][0]; } else { $Rep_Timeoffset[] = $Adapt_Timeoffset; } // if not exist get the upper timeoffset if (!empty($segarray[$i][1])) { $timescale = $segarray[$i][1]; } // get timescale if exist if (!empty($segarray[$i][2])) { $indexRange_RepSet[] = $segarray[$i][2]; } //get index range if it exists } else { $Rep_Timeoffset[] = $Adapt_Timeoffset; } // if not exist get the upper timeoffset for ($j = 0; $j < $repbaseurl->length; $j++) { // Get baseurl and Iterate it $base = $repbaseurl->item($j); // baseURL $lastbase[] = $base->nodeValue; // the last compnent in BaseURL } $rep_url[] = $lastbase; // add them in baseURL $repsegment = $temprep->getElementsByTagName("SegmentTemplate"); //In case presentation use SegmentTemplate $pass_seg = $repsegment->item(0); if ($repsegment->length > 0) { $rep_seg_temp[$i] = processTemplate($pass_seg); } //Process segmentTemplate $idvar = $temprep->getAttribute('id'); // Get presentation ID if (empty($idvar)) { $idvar = 0; } $id[$i] = $idvar; // save id within array of ID //Get some Attributes from Presentation $repStartWithSAP[$i] = $temprep->getAttribute('startWithSAP'); if ($repStartWithSAP[$i] === "") { $repStartWithSAP[$i] = $startWithSAP; } $repProfiles[$i] = $temprep->getAttribute('profiles'); if ($repProfiles[$i] === "") { $repProfiles[$i] = $adapsetProfiles; } $codecsvar = $temprep->getAttribute('codecs'); if (empty($codecsvar)) { $codecsvar = 0; } $codecs[$i] = $codecsvar; $widthvar = $temprep->getAttribute('width'); if (empty($widthvar)) { $widthvar = 0; } $width[$i] = $widthvar; $heightvar = $temprep->getAttribute('height'); if (empty($heightvar)) { $heightvar = 0; } $height[$i] = $heightvar; if (empty($scantypevar)) { $scantypevar = $temprep->getAttribute('scanType'); } if (empty($scantypevar)) { $scantypevar = 0; } $scanType = $scantypevar; $frameRatevar = $temprep->getAttribute('frameRate'); if (empty($frameRatevar)) { $frameRatevar = 0; } $frameRate[$i] = $frameRatevar; $sarvar = $temprep->getAttribute('sar'); if (empty($sarvar)) { $sarvar = 0; } $sar[$i] = $sarvar; $bandwidthvar = $temprep->getAttribute('bandwidth'); if (empty($bandwidthvar)) { $bandwidthvar = 0; } $bandwidth[$i] = $bandwidthvar; if ($temprep->hasAttribute('timescale')) { $timescale = $temprep->getAttribute('timescale'); } $ContentProtectionElementCountRep[$i] = $temprep->getElementsByTagName("ContentProtection")->length; //Process ContentProtection if ($ContentProtectionElementCountRep[$i] == 0) { $ContentProtectionElementCountRep[$i] = $ContentProtection->length; } $audioChannelConfig_Rep = $temprep->getElementsByTagName('AudioChannelConfiguration'); //Check if AudioChannelConfiguration exists if ($audioChannelConfig_Rep->length > 0) { $audioCh_Rep_item = $audioChannelConfig_Rep->item(0); $audioCh_Rep_value = $audioCh_Rep_item->getAttribute('value'); $audioCh_value[$i] = $audioCh_Rep_value; } else { $audioCh_value[$i] = 0; } } } } $Adapt_urlbase = $rep_url; //Incase of using BaseURL just add all BaseURLs within array containint all presentations //Array of each presentation containing all attributes and nodes within Presentations $Rep_arr = array('id' => $id, 'codecs' => $codecs, 'width' => $width, 'height' => $height, 'scanType' => $scanType, 'frameRate' => $frameRate, 'sar' => $sar, 'bandwidth' => $bandwidth, 'SegmentTemplate' => $rep_seg_temp, 'SegmentBase' => $segarray, 'startWithSAP' => $repStartWithSAP, 'profiles' => $repProfiles, 'ContentProtectionElementCount' => $ContentProtectionElementCountRep, 'presentationTimeOffset' => $Rep_Timeoffset, 'timescale' => $timescale, 'AudioChannelValue' => $audioCh_value, 'indexRange' => $indexRange_RepSet); // Array of all adapationsets containing all attributes and nodes including Presentations $Adapt_arr = array('startWithSAP' => $startWithSAP, 'segmentAlignment' => $segmentAlignment, 'subsegmentAlignment' => $subsegmentAlignment, 'bitstreamSwitching' => $bitstreamSwitching, 'id' => $idadapt, 'scanType' => $scanType, 'mimeType' => $mimeType, 'SegmentTemplate' => $Adapt_seg_temp, 'SegmentBase' => $basearray, 'codecs' => $codecs_AdaptSet, 'width' => $width_AdaptSet, 'height' => $height_AdaptSet, 'Representation' => $Rep_arr, 'AudioChannelValue' => $audioCh_Adapt_value, 'indexRange' => $indexRange_AdaptSet); /* $Rep_arr=array('id'=>$id,'codecs'=>$codecs,'width'=>$width,'height'=>$height,'scanType'=>$scanType,'frameRate'=>$frameRate, 'sar'=>$sar,'bandwidth'=>$bandwidth,'SegmentTemplate'=>$rep_seg_temp, 'startWithSAP'=>$repStartWithSAP, 'profiles'=>$repProfiles, 'ContentProtectionElementCount'=>$ContentProtectionElementCountRep,'presentationTimeOffset'=>$Rep_Timeoffset,'timescale'=>$timescale,'AudioChannelValue'=>$audioCh_value); // Array of all adapationsets containing all attributes and nodes including Presentations $Adapt_arr=array('startWithSAP'=>$startWithSAP,'segmentAlignment'=>$segmentAlignment,'subsegmentAlignment'=>$subsegmentAlignment,'bitstreamSwitching'=>$bitstreamSwitching, 'id'=>$idadapt,'scanType'=>$scanType,'mimeType'=>$mimeType,'SegmentTemplate'=>$Adapt_seg_temp,'codecs'=>$codecs_AdaptSet,'width'=>$width_AdaptSet,'height'=>$height_AdaptSet,'Representation'=>$Rep_arr,'AudioChannelValue'=>$audioCh_Adapt_value); */ }
*/ function processTemplate($quoteObject, $customerArray) { //$emailTemplate = Mage::getModel('core/email_template')->loadDefault('quote_request_template'); $emailTemplate = Mage::getModel('core/email_template')->loadDefault('quote_request_template'); //Create an array of variables to assign to template $emailTemplateVariables = array(); //Store quote infos in template object foreach ($quoteObject as $quoteKey => $value) { $emailTemplateVariables[$quoteKey] = $value; } //Store customer infos in template object foreach ($customerArray as $custKey => $value) { $emailTemplateVariables[$custKey] = $value; } /* echo "<pre> email template is : <br/>"; print_r($emailTemplateVariables); echo "</pre>"; */ //$emailTemplateVariables['client_ip'] = $_SERVER['REMOTE_ADDR']; $emailTemplate->setSenderName($emailTemplateVariables['nameField']); $emailTemplate->setSenderEmail($GLOBALS["mail"]); $emailTemplate->setTemplateSubject('Quote request'); $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables); $emailTemplate->send($GLOBALS["admin_Mail"], $emailTemplateVariables['nameField'], $emailTemplateVariables); echo json_encode("Your quote was sent successfully to our team. You'll be contacted shortly. Thanks"); } //Send email... processTemplate($quoteObject, $customerArray); }
function sendEmailTemplate($i_parameters = array()) { global $g_db, $DOCUMENT_ROOT, $DOCUMENT_PAGES, $DOCUMENT_PHPMAILER, $srv_settings; $i_etemplateid = isset($i_parameters['etemplateid']) ? $i_parameters['etemplateid'] : 0; $i_emailto = isset($i_parameters['emailto']) ? $i_parameters['emailto'] : NULL; $i_isok = true; $i_isok = $i_isok && ($i_rSet3 = $g_db->SelectLimit("SELECT etemplate_from, etemplate_subject, etemplate_body FROM " . $srv_settings['table_prefix'] . "etemplates WHERE etemplateid=" . $i_etemplateid, 1)); if ($i_isok) { $i_isok = $i_isok && !$i_rSet3->EOF; } if ($i_isok) { $i_email_body = $i_rSet3->fields['etemplate_body']; if ($i_email_body) { $i_parameters['content_type'] = 'text/plain'; $i_parameters['template_body'] = $i_email_body; $arrTemplateEmail = processTemplate($i_parameters); $i_email_body = $arrTemplateEmail['body']; $i_parameters['template_body'] = $i_rSet3->fields['etemplate_subject']; $arrTemplateEmailSubject = processTemplate($i_parameters); if (!is_array($i_emailto)) { $i_emailto = array($i_rSet3->fields['etemplate_from']); } include_once $DOCUMENT_PHPMAILER . 'class.phpmailer.php'; $mail = new PHPMailer(); $mail->PluginDir = $DOCUMENT_PHPMAILER; $mail->FromName = ''; $mail->From = $i_rSet3->fields['etemplate_from']; $mail->AddReplyTo($i_rSet3->fields['etemplate_from']); $mail->IsHTML(true); $mail->Subject = $arrTemplateEmailSubject['body']; $mail->Body = nl2br($i_email_body); $mail->AltBody = $i_email_body; if (!empty($arrTemplateEmail['attachments'])) { foreach ($arrTemplateEmail['attachments'] as $arrAttachment) { switch ($arrAttachment['format']) { case 'string': $mail->AddStringAttachment($arrAttachment['content'], $arrAttachment['filename'], $arrAttachment['encoding'], $arrAttachment['type']); break; } } } foreach ($i_emailto as $i_emailto_item) { if (!empty($i_emailto_item)) { $mail->AddAddress($i_emailto_item); $mail->Send(); $mail->ClearAddresses(); } } } } }