public function getHTML($small = false) { global $install, $sql; include_once "HTML/Template/Flexy.php"; $config = new Configuracion($sql); $this->data->TITLE = $config->get("Nombre del Sitio"); $map = $config->get("Coordenadas del Mapa"); $marker = $config->get("Coordenadas del Marcador"); if ($map) { $map = split(",", $map); $this->data->MAP = "<script>\nvar lat = " . $map[0] . ";\nvar lon = " . $map[1] . ";\n</script>"; } if ($marker) { $marker = split(",", $marker); $this->data->MARKER = "<script>\nvar latMarker = " . $marker[0] . ";\nvar lonMarker = " . $marker[1] . ";\n</script>"; } $options = array('compileDir' => $install . '/tmp', 'templateDir' => $install . '/template'); if ($small) { $template = "content.small.html"; } else { $template = $this->data->data["TEMPLATECON"]; $cursor = $sql->readDB("TEMPLATE", "ID______TEM={$template}"); $res = $cursor->fetch_assoc(); $template = $res["FILE____TEM"]; } $output = new HTML_Template_Flexy($options); $output->compile($template); return $output->bufferedOutputObject($this->data); }
/** * 出力を返却 * * @return string * @access public */ protected function getOutput() { if ($this->_encoding) { return mb_convert_encoding($this->flexy->bufferedOutputObject($this->_obj, $this->_elements), $this->_encoding['to'], $this->_encoding['from']); } else { return $this->flexy->bufferedOutputObject($this->_obj, $this->_elements); } }
foreach ($options as $k => $v) { $ref[$v] = $k; } $query = "SELECT * FROM " . $ref['TABLE'] . " WHERE " . $ref['INDEX'] . "='" . $value . "';"; $cursor = $sql->query($query); while ($row = $cursor->fetch_assoc()) { $retval = $row[$ref['LABEL']]; } break; case 'thumb': if (empty($value)) { $retval = "<img class=\"thumbnail\" src=\"/thumbnailer/100/100/crop/NoDisponible.jpg\" alt=\"Preview\">"; } else { $retval = "<img class=\"thumbnail\" src=\"/thumbnailer/100/100/crop/{$value}\" alt=\"Preview\">"; } break; default: $retval = $value; break; } //*/ return $retval; } $bread[count($bread) - 1]['active'] = true; $bread[count($bread) - 1]['link'] = false; $tpl->BREAD = $bread; $options = array('templateDir' => 'templates', 'compileDir' => 'tmp'); $output = new HTML_Template_Flexy($options); $output->compile("platos.html"); $tpl->CONTENT = $output->bufferedOutputObject($tpl); include "container.php";
function getInputWidget($key, $value = "", $type = "text") { global $sql; $retval = ''; preg_match('/[a-zA-Z]+/', $type, $matches); preg_match('/\\[[_\\|\\=a-zA-Z0-9]+\\]/', $type, $options); if ($options) { $options = str_replace(array('[', ']'), '', $options[0]); $tmp = explode("|", $options); unset($options); foreach ($tmp as $v) { $tmp = explode("=", $v); $options[$tmp[1]] = $tmp[0]; } } switch ($matches[0]) { case 'radio': foreach ($options as $k => $v) { if ($k != '_bootstrap') { $retval .= "<label class='radio inline'>"; if ($k == $value) { $retval .= "<input type='radio' name='{$key}' value='{$k}' checked='checked'>{$v}"; } else { $retval .= "<input type='radio' name='{$key}' value='{$k}'>{$v}"; } $retval .= "</label>"; } } break; case 'dbcombobox': foreach ($options as $k => $v) { $ref[$v] = $k; } $retval .= "<select name='{$key}' value='{$value}'>"; $query = "SELECT * FROM " . $ref['TABLE'] . ";"; $result = $sql->con->query($query); while ($row = $result->fetch_assoc()) { if ($value == $row[$ref['INDEX']]) { $retval .= "\t<option value='" . $row[$ref['INDEX']] . "' selected>" . $row[$ref['LABEL']] . "</option>"; } else { $retval .= "\t<option value='" . $row[$ref['INDEX']] . "'>" . $row[$ref['LABEL']] . "</option>"; } } $retval .= "</select>"; break; case 'textarea': if ($options) { foreach ($options as $k => $v) { $configs[$v] = $k; } $cols = $configs['cols']; $rows = $configs['rows']; $retval .= "<textarea name='{$key}' cols='{$cols}' rows='{$rows}'>"; } else { $retval .= "<textarea name='{$key}'>"; } $retval .= "{$value}</textarea>"; break; case 'tinyMCE': $retval = "<textarea id='{$key}' name='{$key}'>{$value}</textarea>"; $retval .= "<script src=\"//tinymce.cachefly.net/4.1/tinymce.min.js\"></script>"; $retval .= "<script>tinymce.init({selector:'#{$key}'});</script>"; break; case 'file': if (empty($value)) { $retval = "<img class=\"thumbnail\" src=\"/thumbnailer/200/200/crop/NoDisponible.jpg\" alt=\"Preview\">"; } else { $retval = "<img class=\"thumbnail\" src=\"/thumbnailer/200/200/crop/{$value}\" alt=\"Preview\">"; } $retval .= "<input type='{$type}' name='" . $key . "_file' value='{$value}' onchange='previewImage(this)' width='200'>"; $retval .= "<input type='hidden' name='{$key}' value='{$value}'>"; break; case 'multifile': include_once "HTML/Template/Flexy.php"; $options = array('templateDir' => "inputWidgets/templates", 'compileDir' => "inputWidgets/templates"); $obj = new stdClass(); $obj->KEY = $key; $obj->JAVASCRIPT = "<script>var key = '" . $key . "'</script>"; $tmp = unserialize($value); if (is_array($tmp)) { foreach ($tmp as $tk => $tv) { $obj->FILAS[]['nombre'] = $tv; } } $output = new HTML_Template_Flexy($options); $output->compile('multifile.html'); $retval = $output->bufferedOutputObject($obj); break; default: $retval = "<input type='{$type}' name='{$key}' value='{$value}'>"; break; } return $retval; }
$cursor = $sql->readDB("CONTENIDO", "ESTADO__CON='A'"); while ($row = $cursor->fetch_assoc()) { if (url_slug($row['TITULO__CON']) == substr($_SERVER['REQUEST_URI'], 1)) { $error = false; } if ("contenido=" . $row["ID______CON"] == substr($_SERVER['REQUEST_URI'], 1)) { $error = false; } } $cursor = $sql->readDB("CATEGORIA"); while ($row = $cursor->fetch_assoc()) { if (url_slug($row['NOMBRE__CAT']) == substr($_SERVER['REQUEST_URI'], 1)) { $error = false; } } if (!$error) { Header("HTTP/1.0 200 OK"); $_REQUEST['bufferedHTML'] = true; $_REQUEST['what'] = substr($_SERVER['REQUEST_URI'], 1); include_once "getContent.php"; $content = $retval['html']; $content .= "<script>var error = true; var passedURL = '" . substr($_SERVER['REQUEST_URI'], 1) . "';</script>"; include_once "container.php"; exit; } $options = array('templateDir' => $install . "/template", 'compileDir' => $install . "/tmp"); $object = new HTML_Template_Flexy($options); $object->compile("error.html"); $content = $object->bufferedOutputObject($tpl); $content .= "<script>var error = true; var passedURL = 'home';</script>"; include_once "container.php";
/** * ---------------- Global Tools --------------- */ function toData() { $templateFile = $this->template; $args = (array) $this->contents; $content = clone $this->page; foreach ($args as $k => $v) { $content->{$k} = $v; } $content->msgid = empty($content->msgid) ? md5(time() . rand()) : $content->msgid; $ff = HTML_FlexyFramework::get(); $http_host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : 'pman.HTTP_HOST.not.set'; if (isset($ff->Pman['HTTP_HOST'])) { $http_host = $ff->Pman['HTTP_HOST']; } $content->HTTP_HOST = $http_host; // this should be done by having multiple template sources...!!! require_once 'HTML/Template/Flexy.php'; $tmp_opts = array('site_prefix' => false); if (!empty($this->templateDir)) { $tmp_opts['templateDir'] = $this->templateDir; } $fopts = HTML_FlexyFramework::get()->HTML_Template_Flexy; if (!empty($fopts['DB_DataObject_translator'])) { $tmp_opts['DB_DataObject_translator'] = $fopts['DB_DataObject_translator']; } if (!empty($fopts['locale'])) { $tmp_opts['locale'] = $fopts['locale']; } // local opt's overwrite if (!empty($this->locale)) { $tmp_opts['locale'] = $this->locale; } $htmlbody = false; $html_tmp_opts = $tmp_opts; $htmltemplate = new HTML_Template_Flexy($html_tmp_opts); if (is_string($htmltemplate->resolvePath('mail/' . $templateFile . '.body.html'))) { // then we have a multi-part email... if (!empty($this->html_locale)) { $html_tmp_opts['locale'] = $this->html_locale; } $htmltemplate = new HTML_Template_Flexy($html_tmp_opts); $htmltemplate->compile('mail/' . $templateFile . '.body.html'); $htmlbody = $htmltemplate->bufferedOutputObject($content); $this->htmlbody = $htmlbody; // for the html body, we may want to convert the attachments to images. // var_dump($htmlbody);exit; if ($this->replaceImages) { $htmlbody = $this->htmlbodytoCID($htmlbody); } if ($this->css_embed) { $htmlbody = $this->htmlbodyCssEmbed($htmlbody); } } $tmp_opts['nonHTML'] = true; //print_R($tmp_opts); // $tmp_opts['force'] = true; $template = new HTML_Template_Flexy($tmp_opts); $template->compile('mail/' . $templateFile . '.txt'); /* use variables from this object to ouput data. */ $mailtext = $template->bufferedOutputObject($content); //print_r($mailtext);exit; //echo "<PRE>";print_R($mailtext); /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */ require_once 'Mail/mimeDecode.php'; require_once 'Mail.php'; $decoder = new Mail_mimeDecode($mailtext); $parts = $decoder->getSendArray(); if (PEAR::isError($parts)) { return $parts; //echo "PROBLEM: {$parts->message}"; //exit; } $isMime = false; require_once 'Mail/mime.php'; $mime = new Mail_mime(array('eol' => "\n", 'html_charset' => 'utf-8', 'text_charset' => 'utf-8', 'head_charset' => 'utf-8')); // clean up the headers... $parts[1]['Message-Id'] = '<' . $content->msgid . '@' . $content->HTTP_HOST . '>'; if ($htmlbody !== false) { // got a html headers... if (isset($parts[1]['Content-Type'])) { unset($parts[1]['Content-Type']); } $mime->setTXTBody($parts[2]); $mime->setHTMLBody($htmlbody); // var_dump($mime);exit; foreach ($this->images as $cid => $cdata) { $mime->addHTMLImage($cdata['file'], $cdata['mimetype'], $cid . '.' . $cdata['ext'], true, $cdata['contentid']); } $isMime = true; } if (!empty($this->attachments)) { //if got a attachments $header = $mime->headers($parts[1]); if (isset($parts[1]['Content-Type'])) { unset($parts[1]['Content-Type']); } if (!$isMime) { if (preg_match('/text\\/html/', $header['Content-Type'])) { $mime->setHTMLBody($parts[2]); $mime->setTXTBody('This message is in HTML only'); } else { $mime->setTXTBody($parts[2]); $mime->setHTMLBody('<PRE>' . htmlspecialchars($parts[2]) . '</PRE>'); } } foreach ($this->attachments as $attch) { $mime->addAttachment($attch['file'], $attch['mimetype'], !empty($attch['name']) ? $attch['name'] : '', true); } $isMime = true; } if ($isMime) { $parts[2] = $mime->get(); $parts[1] = $mime->headers($parts[1]); } $ret = array('recipents' => $parts[0], 'headers' => $parts[1], 'body' => $parts[2], 'mailer' => $this); if ($this->rcpts !== false) { $ret['recipents'] = $this->rcpts; } // if 'to' is empty, then add the recipents in there... (must be an array? if (!empty($ret['recipents']) && is_array($ret['recipents']) && (empty($ret['headers']['To']) || !strlen(trim($ret['headers']['To'])))) { $ret['headers']['To'] = implode(',', $ret['recipents']); } // add bcc if necessary.. if (!empty($this->bcc)) { $ret['bcc'] = $this->bcc; } return $ret; }
/** * * * * * FIXME !!!! -- USE Pman_Core_Mailer !!!!! * * * * */ function buildMail($templateFile, $args) { $args = (array) $args; $content = clone $this; foreach ((array) $args as $k => $v) { $content->{$k} = $v; } $ff = HTML_FlexyFramework::get(); //?? is this really the place for this??? if (!$ff->cli && empty($args['no_auth']) && !in_array($templateFile, array('password_reset', 'password_welcome'))) { $content->authUser = $this->getAuthUser(); if (!$content->authUser) { return PEAR::raiseError("Not authenticated"); } } // should handle x-forwarded... $content->HTTP_HOST = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : (isset($ff->HTTP_HOST) ? $ff->HTTP_HOST : 'localhost'); /* use the regex compiler, as it doesnt parse <tags */ $tops = array('compiler' => 'Flexy', 'nonHTML' => true, 'filters' => array('SimpleTags', 'Mail')); if (!empty($args['templateDir'])) { $tops['templateDir'] = $args['templateDir']; } require_once 'HTML/Template/Flexy.php'; $template = new HTML_Template_Flexy($tops); $template->compile("mail/{$templateFile}.txt"); /* use variables from this object to ouput data. */ $mailtext = $template->bufferedOutputObject($content); $htmlbody = false; // if a html file with the same name exists, use that as the body // I've no idea where this code went, it was here before.. if (false !== $template->resolvePath("mail/{$templateFile}.html")) { $tops['nonHTML'] = false; $template = new HTML_Template_Flexy($tops); $template->compile("mail/{$templateFile}.html"); $htmlbody = $template->bufferedOutputObject($content); } //echo "<PRE>";print_R($mailtext); //print_R($mailtext);exit; /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */ require_once 'Mail/mimeDecode.php'; require_once 'Mail.php'; $decoder = new Mail_mimeDecode($mailtext); $parts = $decoder->getSendArray(); if (PEAR::isError($parts)) { return $parts; //echo "PROBLEM: {$parts->message}"; //exit; } list($recipents, $headers, $body) = $parts; $recipents = array($this->email); if (!empty($content->bcc) && is_array($content->bcc)) { $recipents = array_merge($recipents, $content->bcc); } $headers['Date'] = date('r'); if ($htmlbody !== false) { require_once 'Mail/mime.php'; $mime = new Mail_mime(array('eol' => "\n")); $mime->setTXTBody($body); $mime->setHTMLBody($htmlbody); // I think there might be code in mediaoutreach toEmail somewhere // h embeds images here.. $body = $mime->get(); $headers = $mime->headers($headers); } return array('recipients' => $recipents, 'headers' => $headers, 'body' => $body); }
/** * The master Output layer. * * compiles the template * if no caching - just runs the template. * otherwise stores it in the cache. * * you dont normally need to override this. * * called by the page loader. * @access public */ function output() { if (!empty($this->cli)) { return; } /* output the body if no masterTemplate is set */ $options = HTML_FlexyFramework::get(); $type = isset($this->contentType) ? $this->contentType : 'text/html'; header('Content-Type: ' . $type . ';charset=' . (empty($options->charset) ? 'UTF-8' : $options->charset)); if (!$this->masterTemplate) { return $this->outputBody(); } /* master template */ $template_engine = new HTML_Template_Flexy(); $template_engine->compile($this->masterTemplate); if (!$this->_cache || !$this->cacheMethod) { $template_engine->outputObject($this, $this->elements); return; } $id = $this->_cache->generateID($this->getID()); $this->_cache->save($id, $template_engine->bufferedOutputObject($this, $this->elements)); echo $this->_cache->get($id); }
$x = new HTML_Template_Flexy($options); $x->compile('forms.html'); $tmp = new StdClass(); $tmp->xyz = "testing 123"; $elements['List'] = new HTML_Template_Flexy_Element('select'); $elements['List']->setValue(2001); $elements['picture'] = new HTML_Template_Flexy_Element('img', "width='400' height='400' src='any.gif'"); $elements['xhtmllisttest'] = new HTML_Template_Flexy_Element(); $elements['xhtmllisttest']->setOptions(array('0' => '--select something--', 'bbb' => 'somevalue')); $elements['xhtmllisttest']->setValue('bbb'); // write the data to a file. $data = $x->bufferedOutputObject($tmp, $elements); $fh = fopen(dirname(__FILE__) . '/results2/forms.result.html', 'w'); fwrite($fh, $data); fclose($fh); /* ----- functions examples ---------*/ echo "Compiling Function examples\n"; $x = new HTML_Template_Flexy($options); $x->compile('function.html'); $tmp = new StdClass(); $tmp->a_value = "test1"; $data = $x->bufferedOutputObject($tmp, $elements); $fh = fopen(dirname(__FILE__) . '/results2/function.result.html', 'w'); fwrite($fh, $data); fclose($fh); /* ------ block examples ---------*/ echo "Compiling Block examples\n"; $x = new HTML_Template_Flexy($options); $x->compile('blocks.html#block1'); $x = new HTML_Template_Flexy($options); $x->compile('blocks.html#block2');
$proyectos[$f][$rrr['ID______CON']] = $cont->getHTML(true); $c++; if ($c >= 4) { $c = 0; $f++; } } } } } } } if (isset($proyectos[0])) { $tpl->COLS = "3"; if (count($proyectos[0]) < 4) { $tpl->COLS = (string) floor(12 / count($proyectos[0])); } $tpl->TILES = $proyectos; $output = new HTML_Template_Flexy($options); $output->compile("grilla.html"); $html = $output->bufferedOutputObject($tpl); } } } $retval['html'] = $html; } if (!isset($_REQUEST['bufferedHTML'])) { header('Content-type: application/json; charset=utf-8'); print json_encode($retval); exit; }
$config = new Configuracion($sql); $tpl->CONTENT = $content; $tpl->TITLE = $config->get("Nombre del Sitio"); $map = $config->get("Coordenadas del Mapa"); $marker = $config->get("Coordenadas del Marcador"); $cursor = $sql->readDB("CATEGORIA", "PADRE___CAT=-1 AND ID______CAT!=-1"); while ($row = $cursor->fetch_assoc()) { $categoria = array(); $categoria['url'] = url_slug($row['NOMBRE__CAT']); $categoria['nombre'] = strtoupper($row['NOMBRE__CAT']); $subCursor = $sql->readDB("CATEGORIA", "PADRE___CAT=" . $row['ID______CAT']); while ($rr = $subCursor->fetch_assoc()) { $children = array(); $children['url'] = url_slug($rr['NOMBRE__CAT']); $children['nombre'] = strtoupper($rr['NOMBRE__CAT']); $categoria['childrens'][] = $children; } $tpl->CATEGORIAS[] = $categoria; } $cursor = $sql->query("\n\tSELECT\n\t\tFOTOGRANCON\n\tFROM\n\t\tCONTENIDO\n\tWHERE\n\t\tESTADO__CON='A'\n"); $images = array(); while ($row = $cursor->fetch_assoc()) { $images[] = "'/thumbnailer/160/160/crop/" . $row['FOTOGRANCON'] . "'"; } $tpl->IMAGES = "<script>preload(" . join(',', $images) . ");</script>"; $options = array('compileDir' => $install . '/tmp', 'templateDir' => $install . '/template'); $output = new HTML_Template_Flexy($options); $output->compile("menu.html"); $tpl->MENU = $output->bufferedOutputObject($tpl); $output->compile('container.html'); $output->OutputObject($tpl);