示例#1
0
文件: ExpoCrud.php 项目: 318io/318-io
 private static function _gen_hash($field = '')
 {
     do {
         $hash = DT::random_string(6, true);
         $entity_ids = \Drupal::entityQuery('node')->condition($field . '.value', $hash, '=')->execute();
     } while ($entity_ids);
     return $hash;
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $p_visited = DT::array_get($_COOKIE, 'p_visited', false);
     setcookie('p_visited', true);
     $menu = '
         <nav id="block-our318"><div id="expotool"><div class="wrapper"><ul class="menu nav">
         <li><a href="/"><i class="fa fa-home"></i> 首頁</a></li>
         <li><a href="/p/highlight"><i class="fa fa-star"></i> 精選</a></li>
         <li><a href="/ajax-page/node/247" class="ajaxpopup staticpage' . (!$p_visited ? ' ajaxpopup-on-start' : '') . '"><i class="fa fa-info-circle"></i> 關於</a></li>
         <li><a href="/ajax-page/node/166" class="ajaxpopup staticpage"><i class="fa fa-info-circle"></i> 使用</a></li>
         <li><a href="/ajax-page/node/165" class="ajaxpopup staticpage"><i class="fa fa-info-circle"></i> 免責</a></li>
         <li><a href="/p/add"><i class="fa fa-plus-circle"></i> 新增你的個人策展</a></li>
         </ul></div></div></nav>
         ';
     $build = ['#markup' => $menu, '#cache' => ['max-age' => 0]];
     return $build;
 }
示例#3
0
 private static function _gen_random_nid()
 {
     $nids = \Drupal::entityQuery('node')->condition('field_showinfront.value', 1, '=')->execute();
     $nid = DT::random_in_list($nids);
     return $nid;
 }
示例#4
0
 public function content_public318search()
 {
     $qs = trim($_GET['qs']);
     $r = '';
     if ($qs == '') {
         $r .= "請輸入搜尋字(以下為隨機挑選)";
         $public318_ids = [10478, 11857, 11861, 11897, 11902, 11914, 11933, 11940, 11941, 11956, 11960, 11962, 12377, 12378, 12382, 12395, 12578, 12663, 12669, 12681, 12684, 13035, 13049, 13050, 13051, 13064, 13065, 13066, 13067, 13070, 13076, 13077, 13078, 13100, 13121, 13122, 13130, 13135, 13136, 13138, 13140, 13142, 13144, 13145, 13149, 13173, 13182, 13202, 13225, 13253, 13255, 13258, 13259, 13260, 13264, 13265, 13266, 13267, 13292, 13305, 13313, 13325, 13328, 13329, 13343, 13348, 13349, 13350, 13351, 13352, 13353, 13354, 13356, 13377, 13391, 13394, 13395, 13396, 13413, 13416, 13428, 14944, 14945, 14946, 14948, 14951, 14952, 14953, 14954, 14955, 14956, 14957, 14959, 14960, 14961, 14962, 14963, 14967, 14968, 14969, 14970, 14971, 14972];
         $cc = count($public318_ids);
         $tt = DT::random_num_list(0, $cc - 1, 18);
         $ids = [];
         foreach ($tt as $tk) {
             $ids[] = $public318_ids[$tk];
         }
         $qs = implode(',', $ids);
         $select = self::_content_public318search_search($qs);
         if ($select === false) {
             $r .= "找不到...";
         } else {
             $r .= $select;
         }
     } else {
         $select = self::_content_public318search_search($qs);
         if ($select === false) {
             $r .= "找不到...";
         } else {
             $r .= $qs;
             $r .= $select;
         }
     }
     echo $r;
     die;
 }
示例#5
0
文件: ExpoGen.php 项目: 318io/318-io
 private static function _getRandomItems($storymax, $stickymax, $min, $max)
 {
     $story_cc = DT::random_num_list(4, 35, $storymax);
     $cc = DT::random_num_list($min, $max, $stickymax - $storymax);
     $ins_cc = DT::random_num_list(0, $stickymax - 1, $storymax);
     sort($ins_cc);
     $sss = array();
     $k = 0;
     for ($j = 0; $j < $stickymax; $j++) {
         if (in_array($j, $ins_cc)) {
             $id = array_shift($story_cc);
             $sss[] = array('itemtype' => 'story', 'id' => $id);
         } else {
             $id = array_shift($cc);
             $sss[] = array('itemtype' => 'public318', 'id' => $id);
         }
     }
     return $sss;
 }