當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Format::searchable方法代碼示例

本文整理匯總了PHP中Format::searchable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Format::searchable方法的具體用法?PHP Format::searchable怎麽用?PHP Format::searchable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Format的用法示例。


在下文中一共展示了Format::searchable方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: IndexOldStuff

 /**
  * Cooperates with the cron system to automatically find content that is
  * not index in the _search table and add it to the index.
  */
 function IndexOldStuff()
 {
     $class = get_class();
     $auto_create = function ($db_error) use($class) {
         if ($db_error != 1146) {
             // Perform the standard error handling
             return true;
         }
         // Create the search table automatically
         $class::__init();
     };
     // THREADS ----------------------------------
     $sql = "SELECT A1.`id`, A1.`title`, A1.`body`, A1.`format` FROM `" . TICKET_THREAD_TABLE . "` A1\n            LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='H')\n            WHERE A2.`object_id` IS NULL AND (A1.poster <> 'SYSTEM')\n            AND (LENGTH(A1.`title`) + LENGTH(A1.`body`) > 0)\n            ORDER BY A1.`id` DESC";
     if (!($res = db_query_unbuffered($sql, $auto_create))) {
         return false;
     }
     while ($row = db_fetch_row($res)) {
         $body = ThreadBody::fromFormattedText($row[2], $row[3]);
         $body = $body->getSearchable();
         $title = Format::searchable($row[1]);
         if (!$body && !$title) {
             continue;
         }
         $record = array('H', $row[0], $title, $body);
         if (!$this->__index($record)) {
             return;
         }
     }
     // TICKETS ----------------------------------
     $sql = "SELECT A1.`ticket_id` FROM `" . TICKET_TABLE . "` A1\n            LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`ticket_id` = A2.`object_id` AND A2.`object_type`='T')\n            WHERE A2.`object_id` IS NULL\n            ORDER BY A1.`ticket_id` DESC";
     if (!($res = db_query_unbuffered($sql, $auto_create))) {
         return false;
     }
     while ($row = db_fetch_row($res)) {
         $ticket = Ticket::lookup($row[0]);
         $cdata = $ticket->loadDynamicData();
         $content = array();
         foreach ($cdata as $k => $a) {
             if ($k != 'subject' && ($v = $a->getSearchable())) {
                 $content[] = $v;
             }
         }
         $record = array('T', $ticket->getId(), Format::searchable($ticket->getNumber() . ' ' . $ticket->getSubject()), implode("\n", $content));
         if (!$this->__index($record)) {
             return;
         }
     }
     // USERS ------------------------------------
     $sql = "SELECT A1.`id` FROM `" . USER_TABLE . "` A1\n            LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='U')\n            WHERE A2.`object_id` IS NULL\n            ORDER BY A1.`id` DESC";
     if (!($res = db_query_unbuffered($sql, $auto_create))) {
         return false;
     }
     while ($row = db_fetch_row($res)) {
         $user = User::lookup($row[0]);
         $cdata = $user->getDynamicData();
         $content = array();
         foreach ($user->emails as $e) {
             $content[] = $e->address;
         }
         foreach ($cdata as $e) {
             foreach ($e->getAnswers() as $a) {
                 if ($c = $a->getSearchable()) {
                     $content[] = $c;
                 }
             }
         }
         $record = array('U', $user->getId(), Format::searchable($user->getFullName()), trim(implode("\n", $content)));
         if (!$this->__index($record)) {
             return;
         }
     }
     // ORGANIZATIONS ----------------------------
     $sql = "SELECT A1.`id` FROM `" . ORGANIZATION_TABLE . "` A1\n            LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='O')\n            WHERE A2.`object_id` IS NULL\n            ORDER BY A1.`id` DESC";
     if (!($res = db_query_unbuffered($sql, $auto_create))) {
         return false;
     }
     while ($row = db_fetch_row($res)) {
         $org = Organization::lookup($row[0]);
         $cdata = $org->getDynamicData();
         $content = array();
         foreach ($cdata as $e) {
             foreach ($e->getAnswers() as $a) {
                 if ($c = $a->getSearchable()) {
                     $content[] = $c;
                 }
             }
         }
         $record = array('O', $org->getId(), Format::searchable($org->getName()), trim(implode("\n", $content)));
         if (!$this->__index($record)) {
             return null;
         }
     }
     // KNOWLEDGEBASE ----------------------------
     require_once INCLUDE_DIR . 'class.faq.php';
     $sql = "SELECT A1.`faq_id` FROM `" . FAQ_TABLE . "` A1\n            LEFT JOIN `" . TABLE_PREFIX . "_search` A2 ON (A1.`faq_id` = A2.`object_id` AND A2.`object_type`='K')\n            WHERE A2.`object_id` IS NULL\n            ORDER BY A1.`faq_id` DESC";
     if (!($res = db_query_unbuffered($sql, $auto_create))) {
//.........這裏部分代碼省略.........
開發者ID:KM-MFG,項目名稱:osTicket-1.8,代碼行數:101,代碼來源:class.search.php

示例2: getSearchable

 function getSearchable($include_label = false)
 {
     if ($include_label) {
         $label = Format::searchable($this->getField()->getLabel()) . " ";
     }
     return sprintf("%s%s", $label, $this->getField()->searchable($this->getValue()));
 }
開發者ID:dmiguel92,項目名稱:osTicket-1.8,代碼行數:7,代碼來源:class.dynamic_forms.php

示例3: getSearchable

 function getSearchable()
 {
     // <br> -> \n
     $body = preg_replace(array('`<br(\\s*)?/?>`i', '`</div>`i'), "\n", $this->body);
     $body = Format::htmldecode(Format::striptags($body));
     return Format::searchable($body);
 }
開發者ID:CarlosAvilesMx,項目名稱:CarlosAviles.Mx,代碼行數:7,代碼來源:class.thread.php

示例4: searchable

 function searchable($value)
 {
     $value = preg_replace(array('`<br(\\s*)?/?>`i', '`</div>`i'), "\n", $value);
     $value = Format::htmldecode(Format::striptags($value));
     return Format::searchable($value);
 }
開發者ID:gizur,項目名稱:osticket,代碼行數:6,代碼來源:class.forms.php

示例5: getSearchable

 function getSearchable()
 {
     // Replace tag chars with spaces (to ensure words are separated)
     $body = Format::html($this->body, array('hook_tag' => function ($el, $attributes = 0) {
         static $non_ws = array('wbr' => 1);
         return isset($non_ws[$el]) ? '' : ' ';
     }));
     // Collapse multiple white-spaces
     $body = html_entity_decode($body, ENT_QUOTES);
     $body = preg_replace('`\\s+`u', ' ', $body);
     return Format::searchable($body);
 }
開發者ID:jmangarret,項目名稱:ostickets,代碼行數:12,代碼來源:class.thread.php


注:本文中的Format::searchable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。