{"id":611,"date":"2012-06-11T09:43:29","date_gmt":"2012-06-11T09:43:29","guid":{"rendered":"http:\/\/cowman-chiang.no-ip.org\/wordpress\/?p=611"},"modified":"2023-10-31T15:52:28","modified_gmt":"2023-10-31T07:52:28","slug":"clipbucket-%e4%bf%ae%e6%ad%a3%e5%bd%b1%e7%89%87%e6%a8%99%e9%a1%8c%e4%b8%ad%e6%96%87%e5%85%a7%e5%ae%b9%e8%a2%ab%e6%88%aa%e5%8f%96%e6%88%90%e4%ba%82%e7%a2%bc","status":"publish","type":"post","link":"https:\/\/cowmanchiang.me\/wp\/?p=611","title":{"rendered":"ClipBucket \u4fee\u6b63\u5f71\u7247\u6a19\u984c\u4e2d\u6587\u5167\u5bb9\u88ab\u622a\u53d6\u6210\u4e82\u78bc"},"content":{"rendered":"<p>\u4e3b\u8981\u662f\u56e0\u70batruncate\u5c0d\u65bc\u4e2d\u6587\u7684\u8fa8\u8b58\u4e0d\u592a\u6b63\u78ba<br \/>\n\u4ee5\u81f3\u65bc\u6703\u628a\u4e2d\u6587\u62c6\u89e3\u932f\u8aa4\uff0c\u56e0\u6b64\u9700\u8981\u4fee\u6539\u00a0modifier.truncate.php<\/p>\n<p>\u53c3\u8003\u4e86\u7db2\u8def\u4e0a\u7684\u6587\u7ae0\uff1a<a href=\"http:\/\/beatskate.com\/smarty-truncate\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u8b93 Smarty \u7684 truncate \u652f\u63f4 UTF-8 \u7684\u65b9\u6cd5<\/a><br \/>\n\u5c31\u958b\u59cb\u4f86\u52d5\u624b\u5427<\/p>\n<p><code>vim \/var\/www\/html\/includes\/templatelib\/plugins\/modifier.truncate.php<\/code><br \/>\n<!--more--><br \/>\n\u9019\u88e1\u4e3b\u8981\u662f\u8981\u628afunction smarty_modifier_truncate\u9019\u500bfunction\u7684\u5167\u5bb9\u6574\u500b\u7f6e\u63db\u6389<\/p>\n<pre lang=\"PHP\">\n  if ($length == 0)\n    return '';\n  $string = html_entity_decode(trim(strip_tags($string)), ENT_QUOTES, 'utf-8');\n  for($i = 0, $j = 0; $i < strlen($string); $i++)\n  {\n    if($j >= $length)\n    {\n      for($x = 0, $y = 0; $x < strlen($etc); $x++)\n      {\n        if($number = strpos(str_pad(decbin(ord(substr($string, $i, 1))), 8, '0', STR_PAD_LEFT), '0'))\n        {\n          $x += $number - 1;\n          $y++;\n        }\n        else\n          $y += 0.5;\n      }\n      $length -= $y;\n      break;\n    }\n    if($number = strpos(str_pad(decbin(ord(substr($string, $i, 1))), 8, '0', STR_PAD_LEFT), '0'))\n    {\n      $i += $number - 1;\n      $j++;\n    }\n      else\n        $j += 0.5;\n  }\n  for($i = 0; (($i < strlen($string)) &#038;&#038; ($length > 0)); $i++)\n  {\n    if($number = strpos(str_pad(decbin(ord(substr($string, $i, 1))), 8, '0', STR_PAD_LEFT), '0'))\n    {\n      if($length < 1.0)\n        break;\n      $result .= substr($string, $i, $number);\n      $length -= 1.0;\n      $i += $number - 1;\n    }\n    else\n    {\n      $result .= substr($string, $i, 1);\n      $length -= 0.5;\n    }\n  }\n  $result = htmlentities($result, ENT_QUOTES, 'utf-8');\n  if($i < strlen($string))\n    $result .= $etc;\n  return $result;\n<\/pre>\n<p>\u7136\u5f8c\u5c31\u53ef\u4ee5\u4e86~<br \/>\n\u8a18\u5f97\u8981\u9806\u4fbf\u4fee\u6539video.html<br \/>\n\u4e0d\u7136\u6703\u767c\u73fe\u4ed6\u600e\u9ebc\u628a\u6240\u6709\u7684\u4e2d\u6587\u5b57\u90fd\u53eb\u51fa\u4f86\u4e86<\/p>\n<p><code>vim \/var\/www\/html\/styles\/cbv2new\/layout\/blocks\/video.html<\/code><\/p>\n<pre lang=\"PHP\">\n  #\u5927\u7d04\u7b2c19\u884c\n  <h2 class=\"title truncatedtitle\"><a href=\"{videoLink vdetails=$video}\" title=\"{$video.title}\">{$video.title|truncate:40}<\/a><\/h2>\n  #\u5c0740\u4fee\u6539\u621015\n  <h2 class=\"title truncatedtitle\"><a href=\"{videoLink vdetails=$video}\" title=\"{$video.title}\">{$video.title|truncate:15}<\/a><\/h2>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u8981\u662f\u56e0\u70batruncate\u5c0d\u65bc\u4e2d\u6587\u7684\u8fa8\u8b58\u4e0d\u592a\u6b63\u78ba \u4ee5\u81f3\u65bc\u6703\u628a\u4e2d\u6587\u62c6\u89e3\u932f\u8aa4\uff0c\u56e0\u6b64\u9700\u8981\u4fee\u6539\u00a0modifier.truncate.php \u53c3\u8003\u4e86\u7db2\u8def\u4e0a\u7684\u6587\u7ae0\uff1a\u8b93 Smarty \u7684 truncate \u652f\u63f4 UTF-8 \u7684\u65b9\u6cd5 \u5c31\u958b\u59cb\u4f86\u52d5\u624b\u5427 vim \/var\/www\/html\/includes\/templatelib\/plugins\/modifier.truncate.php<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-611","post","type-post","status-publish","format-standard","hentry","category-clipbucket"],"_links":{"self":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=611"}],"version-history":[{"count":1,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/611\/revisions"}],"predecessor-version":[{"id":2125,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/611\/revisions\/2125"}],"wp:attachment":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}