<tbody> <thead> <tr> <th>Artista / Intérprete</th> <th></th> </tr> </thead> <?php if (count($pager) > 0) { ?> <?php $counter = 0; foreach ($pager->getResults() as $d) { $counter++; if ($counter > 30) { $new_slug = str_ireplace("Por ", "", slugfy($d->getDescription())); $new_slug = str_ireplace("e-039-", "", $new_slug); //Martnália ?> <tr> <td><a href="/artistas/<?php echo $new_slug; ?> "><?php echo str_ireplace("Por ", "", $d->getDescription()); ?> </a></td> <td class="play"><a href="/artistas/<?php echo $new_slug; ?> " class="btn btn-mini btn-inverse pull-right" ><i class="icon-list icon-white"></i> listar musicas </a></td>
<tr> <td><a href="<?php echo url_for('@homepage'); ?> artistas/<?php echo slugfy($d->getDescription()); ?> "><?php echo str_ireplace("Por ", "", $d->getDescription()); ?> </a></td> <td class="play"><a href="<?php echo url_for('@homepage'); ?> artistas/<?php echo slugfy($d->getDescription()); ?> " class="btn btn-mini btn-inverse pull-right" ><i class="icon-list icon-white"></i> listar musicas </a></td> </tr> <?php } ?> <?php } ?> <?php } ?> </tbody> </table> </div>
public function executeRadarbuscaartista(sfWebRequest $request) { $this->setLayout(false); if ($request->getParameter('busca-input') != "") { function slugfy($string) { $array1 = array("á", "à", "â", "ã", "ä", "é", "è", "ê", "ë", "í", "ì", "î", "ï", "ó", "ò", "ô", "õ", "ö", "ú", "ù", "û", "ü", "ç", "Á", "À", "Â", "Ã", "Ä", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ó", "Ò", "Ô", "Õ", "Ö", "Ú", "Ù", "Û", "Ü", "Ç"); $array2 = array("a", "a", "a", "a", "a", "e", "e", "e", "e", "i", "i", "i", "i", "o", "o", "o", "o", "o", "u", "u", "u", "u", "c", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "I", "I", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C"); $string = str_replace($array1, $array2, $string); $string = str_ireplace("'", "", $string); $string = str_ireplace("&", "e", $string); $text = preg_replace('~[^\\pL\\d]+~u', '-', $string); // trim $text = trim($text, '-'); // transliterate if (function_exists('iconv')) { $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); } // lowercase $text = strtolower($text); // remove unwanted characters $text = preg_replace('~[^-\\w]+~', '', $text); if (empty($text)) { $text = 'n-a'; } $slug = $text; return str_replace("por-", "", str_replace(" ", "", $slug)); } $busca_input = $request->getParameter('busca-input'); $assetsQuery = Doctrine_Query::create()->select('DISTINCT description as description')->from('Asset a')->where('description LIKE ?', 'Por %' . $request->getParameter('busca-input') . '%')->andWhere('site_id = 189')->orderBy('a.description'); $countQuery = Doctrine_Query::create()->select('COUNT(DISTINCT description) as description')->from('Asset a')->where('description LIKE ?', 'Por %' . $request->getParameter('busca-input') . '%')->andWhere('site_id = 189')->fetchArray(); $pagelimit = 20; if ($request->getParameter('page') != "") { $pagina_atual = $request->getParameter('page'); } $pager = new sfDoctrinePager('', $pagelimit); $pager->setQuery($assetsQuery); $pager->setPage($request->getParameter('page', isset($pagina_atual))); $pager->init(); $pager->setNbResults($countQuery[0]["description"]); $pager->setLastPage(ceil($countQuery[0]["description"] / $pagelimit)); $page = $request->getParameter('page'); if ($request->getParameter('page') > 0) { $page = $request->getParameter('page'); } $resultado = '<table class="table table-striped artista"> <tbody> <thead> <tr> <th>Artista / Intérprete</th> <th></th> </tr> </thead>'; if (count($pager) > 0) { $counter = 0; foreach ($pager->getResults() as $d) { //if($counter >= 25) //break; //$counter++; $resultado .= '<tr> <td><a href="http://radarcultura.cmais.com.br/artistas/' . slugfy($d->getDescription()) . '">' . str_ireplace("Por ", "", $d->getDescription()) . '</a></td> <td><a href="http://radarcultura.cmais.com.br/artistas/' . slugfy($d->getDescription()) . '" class="btn btn-mini btn-inverse pull-right" > <i class="icon-list icon-white"></i> listar musicas </a></td> </tr>'; } } $resultado .= '</tbody> </table>'; if (isset($pager)) { if ($pager->haveToPaginate()) { $paginacao = ' <div class="pagination pagination-centered"> <ul> <li class=""><a href="javascript: goToPage(' . $pager->getFirstPage() . ');" class="paginacao" title="Primeira"><i class="icon-fast-backward"></i></a></li> <li class=""><a href="javascript: goToPage(' . $pager->getPreviousPage() . ');" class="paginacao" title="Anterior"><i class="icon-backward"></i></a></li> '; foreach ($pager->getLinks() as $page) { $paginacao .= '<li '; if ($page == $pager->getPage()) { $paginacao .= 'class="active"'; } $paginacao .= '><a href="javascript: goToPage(' . $page . ');">' . $page . '</a></li>'; } $paginacao .= '<li class=""><a href="javascript: goToPage(' . $pager->getNextPage() . ');" class="paginacao" title="Próximo"><i class="icon-forward"></i></a></li> <li class=""><a href="javascript: goToPage(' . $pager->getLastPage() . ');" class="paginacao" title="Última"><i class="icon-fast-forward"></i></a></li> </ul> </div> <form id="page_form" action="" method="GET"> <input type="hidden" name="page" id="page" value="" /> <input type="hidden" name="busca-input" id="busca-input" value="' . $busca_input . '" /> </form> <script> function goToPage(i){ $("#page").val(i); $("#resultado_busca").html(""); $.ajax({ type : "GET", dataType: "jsonp", data: $("#page_form").serialize(), url: "http://app.cmais.com.br/ajax/radar-artista", success: function(json){ $("#qtd_result").text(json.qtd_result); $("#resultado_busca").html(json.data); $("#resultado_paginacao").html(json.paginacao); } }); } </script>'; } } $a["qtd_result"] = count($pager); $a["data"] = $resultado; $a["paginacao"] = $paginacao; $json = json_encode($a); $callback = $request->getParameter('callback'); echo $callback . '(' . $json . ');'; } die; }
/** * Updates a product in database */ function update_product(array $product) { $db = get_connection(); $sql = <<<SQL UPDATE products SET name = :name, slug = :slug, price = :price, brand = :brand, description = :description, categories = :categories WHERE id = :id SQL; $statement = $db->prepare($sql); $statement->execute([':id' => $product['id'], ':name' => $product['name'], ':slug' => slugfy($product['name']), ':price' => $product['price'], ':brand' => $product['brand'], ':description' => $product['description'], ':categories' => $product['categories']]); }