Example #1
0
function appnet_expand_entities($a, $body, $entities)
{
    if (!function_exists('substr_unicode')) {
        function substr_unicode($str, $s, $l = null)
        {
            return join("", array_slice(preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY), $s, $l));
        }
    }
    $tags_arr = array();
    $replace = array();
    foreach ($entities["mentions"] as $mention) {
        $url = "@[url=https://alpha.app.net/" . rawurlencode($mention["name"]) . "]" . $mention["name"] . "[/url]";
        $tags_arr["@" . $mention["name"]] = $url;
        $replace[$mention["pos"]] = array("pos" => $mention["pos"], "len" => $mention["len"], "replace" => $url);
    }
    foreach ($entities["hashtags"] as $hashtag) {
        $url = "#[url=" . $a->get_baseurl() . "/search?tag=" . rawurlencode($hashtag["name"]) . "]" . $hashtag["name"] . "[/url]";
        $tags_arr["#" . $hashtag["name"]] = $url;
        $replace[$hashtag["pos"]] = array("pos" => $hashtag["pos"], "len" => $hashtag["len"], "replace" => $url);
    }
    foreach ($entities["links"] as $links) {
        $url = "[url=" . $links["url"] . "]" . $links["text"] . "[/url]";
        if (isset($links["amended_len"]) and $links["amended_len"] > $links["len"]) {
            $replace[$links["pos"]] = array("pos" => $links["pos"], "len" => $links["amended_len"], "replace" => $url);
        } else {
            $replace[$links["pos"]] = array("pos" => $links["pos"], "len" => $links["len"], "replace" => $url);
        }
    }
    if (sizeof($replace)) {
        krsort($replace);
        foreach ($replace as $entity) {
            $pre = substr_unicode($body, 0, $entity["pos"]);
            $post = substr_unicode($body, $entity["pos"] + $entity["len"]);
            //$pre = iconv_substr($body, 0, $entity["pos"], "UTF-8");
            //$post = iconv_substr($body, $entity["pos"] + $entity["len"], "UTF-8");
            $body = $pre . $entity["replace"] . $post;
        }
    }
    return array("body" => $body, "tags" => implode($tags_arr, ","));
}
         <div align="left">
             <label class='medicionTxt' style="padding: 3px 10px; border-radius: 3px; font-size: larger;">
                 <?php 
     echo substr($_SESSION['datosForm']['seguimiento'][$i]['Responsable'], 0, 19) . "...";
     ?>
             </label>
         </div>
     </td>
     <td></td>
     <td colspan="2">
     <?php 
     //veo si hay observaciones, si las hay las presento en un jquery.baloon
     $observaciones = '';
     if (trim($_SESSION['datosForm']['seguimiento'][$i]['strSeguimiento']) !== "") {
         //he puesto trim porque hay registro con un espacio en blanco
         $observaciones = "<a class='observaciones' title='" . $_SESSION['datosForm']['seguimiento'][$i]['strSeguimiento'] . "'>" . "<label class='medicionTxt' style='padding: 3px 10px; border-radius: 3px; font-size: larger;'>" . substr_unicode($_SESSION['datosForm']['seguimiento'][$i]['strSeguimiento'], 0, 40) . " ..." . "</label></a>";
     }
     ?>
         <div align="left">
             <label>
                 <?php 
     echo $observaciones;
     ?>
             </label>
         </div>
     </td>
 </tr>
 <tr>
     <td height="5px"></td>
 </tr>
 <?php 
        $nav_btn_disable = array('nav_first' => 0, 'nav_prev' => 0, 'nav_next' => 1, 'nav_last' => 1);
    } elseif ($targetPage == $totalPages) {
        $nav_btn_disable = array('nav_first' => 1, 'nav_prev' => 1, 'nav_next' => 0, 'nav_last' => 0);
    } else {
        $nav_btn_disable = array('nav_first' => 1, 'nav_prev' => 1, 'nav_next' => 1, 'nav_last' => 1);
    }
    $startIndex = ($targetPage - 1) * $rowsPerPage;
    $categoryListString = '';
    $i = $startIndex + 1;
    $category_qry = exec_query_utf8("SELECT * FROM tblcategory WHERE categoryType={$cateTypeid} {$sql_condition} ORDER BY categoryTitle ASC LIMIT " . $startIndex . ",{$rowsPerPage}");
    while ($category_row = mysqli_fetch_assoc($category_qry)) {
        $active = $category_row['active'];
        $categoryListString .= '<tr>
									<td class="tableCellCenter">' . $i . '</td>                                    
                                    <td class="tableCellCenter">' . $category_row['categoryTitle'] . '</td>
                                    <td>' . substr_unicode(strip_tags($category_row['description']), 0, 300) . '...</td>
                                    <td class="tableCellCenter">' . $category_row['icon'] . '</td>
									<td>' . $category_row['datetime'] . '</td>
									<td class="tableCellCenter action_td_verticle">
										<div><button class="btn btn-primary btn-xs" onclick="iniEditCateItem(' . $category_row['id'] . ');"><i class="fa fa-pencil-square-o"></i> Edit</button></div>
										<div><button type="submit" class="btn btn-primary btn-xs" style="' . ($active == 0 ? 'background:#ec6513;' : '') . '" onclick="comfirmCateItemDisable(' . $category_row['id'] . ',' . $active . ')" >' . ($active == 1 ? '<i class="fa fa-lock"></i> Deactivate' : '<i class="fa fa-unlock-alt"></i> Activate') . '</button></div>
									</td>
                               </tr>';
        $i++;
    }
    if ($categoryListString == '') {
        $categoryListString = '<tr><td colspan="6" style="text-align:center; color:#c0434d;"><i class="fa fa-frown-o"></i> No Category Found</td></tr>';
    }
    $data = array('list' => $categoryListString, 'targetPage' => $targetPage, 'totalPages' => $totalPages, 'gotoSelectNum' => $gotoSelectNum, 'nav_btn_disable' => $nav_btn_disable);
    echo json_encode($data);
} elseif ($cmd == 'disableCateItem_block') {
Example #4
0
function shortenStr($str, $len = 0)
{
    $newstr = '';
    if ($len == 0) {
        $len = 10;
    }
    $newstr = substr_unicode($str, 0, $len);
    return $newstr;
}