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


PHP General::countWords方法代碼示例

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


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

示例1: processRawFieldData

 public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null)
 {
     $status = self::__OK__;
     $formatted = $this->applyFormatting($data);
     $result = array('handle' => $this->createHandle($formatted, $entry_id), 'value' => trim((string) $data), 'value_formatted' => $formatted, 'word_count' => General::countWords($data));
     return $result;
 }
開發者ID:hotdoy,項目名稱:EDclock,代碼行數:7,代碼來源:field.textbox.php

示例2: grab


//.........這裏部分代碼省略.........
                         $author = new XMLElement("author");
                         $author_fields = array("first-name" => $author_rec['firstname'], "last-name" => $author_rec['lastname'], "email" => $author_rec['email'], "username" => $author_rec['username']);
                         $this->__addChildFieldsToXML($author_fields, $author, "author");
                         $entry->addChild($author);
                         ##Custom Fields
                         $fields = $row['fields'];
                         if (is_array($fields) && !empty($fields)) {
                             $customFields = new XMLElement("fields");
                             foreach ($fields as $f) {
                                 if (@in_array($f['field_handle'], $this->_dsFilterXMLFIELDS)) {
                                     $newField = new XMLElement($f['field_handle']);
                                     if ($f['type'] == 'list' || $f['type'] == 'multiselect') {
                                         foreach ($f['value_raw'] as $val) {
                                             $item = new XMLElement("item", $val);
                                             $item->setAttribute("handle", Lang::createHandle($val, $this->_parent->getConfigVar('handle_length', 'admin')));
                                             $newField->addChild($item);
                                         }
                                     } elseif ($f['type'] == 'foreign') {
                                         $sid = $f['foreign_section'];
                                         $section_handle = $this->_db->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` WHERE `id` = '{$sid} ' LIMIT 1");
                                         $newField->setAttribute("handle", $f['handle']);
                                         $newField->setAttribute("type", 'foreign');
                                         $newField->setAttribute("section-id", $sid);
                                         $newField->setAttribute("section-handle", $sid);
                                         if (!is_array($f['value_raw'])) {
                                             $f['value_raw'] = array($f['value_raw']);
                                         }
                                         foreach ($f['value_raw'] as $h) {
                                             $entry_id = $entryManager->fetchEntryIDFromPrimaryFieldHandle($sid, $h);
                                             $e = $entryManager->fetchEntriesByID($entry_id, false, true);
                                             $item = new XMLElement("item", trim($e['fields'][$e['primary_field']]['value']));
                                             $item->setAttribute("entry-id", $entry_id[0]);
                                             $item->setAttribute("entry-handle", $e['fields'][$e['primary_field']]['handle']);
                                             $newField->addChild($item);
                                         }
                                     } elseif ($f['type'] == 'upload') {
                                         foreach ($f['value_raw'] as $val) {
                                             $item = new XMLElement("item");
                                             $item->addChild(new XMLElement("path", trim($val['path'], '/')));
                                             $item->addChild(new XMLElement("type", $val['type']));
                                             $item->addChild(new XMLElement("size", General::formatFilesize($val['size'])));
                                             $newField->addChild($item);
                                         }
                                     } elseif ($f['type'] == 'checkbox') {
                                         $newField->setValue($f['value_raw']);
                                     } elseif ($f['type'] == 'select') {
                                         $newField->setValue($f['value_raw']);
                                         $newField->setAttribute("handle", $f['handle']);
                                     } else {
                                         $key = 'value';
                                         if ($f['format'] != 1) {
                                             $key = 'value_raw';
                                         }
                                         $f[$key] = trim($f[$key]);
                                         $value = $f[$key];
                                         if ($this->_dsFilterENCODE == "yes") {
                                             $value = trim(General::sanitize($f[$key]));
                                         }
                                         if ($f['type'] == 'textarea') {
                                             $newField->setValue($value);
                                             $newField->setAttribute("word-count", General::countWords(strip_tags($f['value'])));
                                         } elseif ($f['type'] == 'input' && $f['field_id'] != $row['primary_field']) {
                                             $newField->setAttribute("handle", $f['handle']);
                                             $newField->setValue($value);
                                         }
                                     }
                                     $customFields->addChild($newField);
                                 }
                             }
                             $entry->addChild($customFields);
                         }
                         ##Comments
                         $commenting = $this->_db->fetchVar('commenting', 0, "SELECT `commenting` FROM `tbl_sections` WHERE `id` = '{$section_id}' LIMIT 1");
                         if ($commenting == 'on') {
                             $comments = new XMLElement("comments");
                             $sql = "SELECT  count(*) as `count` " . "FROM `tbl_comments` " . "WHERE `entry_id` = '" . $row['id'] . "'";
                             $comment_count = max(0, @intval($this->_db->fetchVar("count", 0, $sql . " AND `spam` = 'no'")));
                             $spam_count = max(0, @intval($this->_db->fetchVar("count", 0, $sql . " AND `spam` = 'yes'")));
                             $comments->setAttribute("count", "" . $comment_count . "");
                             $comments->setAttribute("spam", "" . $spam_count . "");
                             $entry->addChild($comments);
                         }
                         $xDay->addChild($entry);
                     }
                     $xMonth->addChild($xDay);
                 }
                 $xYear->addChild($xMonth);
             }
             $xml->addChild($xYear);
         }
     }
     ##------------------------------
     ##Write To Cache
     if ($param['caching']) {
         $result = $xml->generate($param['indent'], $param['indent-depth']);
         $this->write_to_cache($hash_id, $result, $this->_cache_sections);
         return $result;
     }
     return $xml;
 }
開發者ID:symphonycms,項目名稱:symphony-1.7,代碼行數:101,代碼來源:data.archive_entry_list.php

示例3: appendFormattedElement

 function appendFormattedElement(&$wrapper, $data, $encode = false)
 {
     if ($this->get('formatter') && isset($data['value_formatted'])) {
         $value = $data['value_formatted'];
     } else {
         $value = $data['value'];
     }
     $value = trim($value);
     $wrapper->appendChild(new XMLElement($this->get('element_name'), $encode ? General::sanitize($value) : $value, array('word-count' => General::countWords($value))));
 }
開發者ID:njmcgee,項目名稱:taxcheck,代碼行數:10,代碼來源:field.textarea.php

示例4: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false)
 {
     if ($this->get('formatter') && isset($data['value_formatted'])) {
         $value = $data['value_formatted'];
     } else {
         $value = $data['value'];
     }
     $value = preg_replace('/&(?!(#[0-9]+|#x[0-9a-f]+|amp|lt|gt);)/i', '&', trim($value));
     $wrapper->appendChild(new XMLElement($this->get('element_name'), $encode ? General::sanitize($value) : $value, array('word-count' => General::countWords($value))));
 }
開發者ID:bauhouse,項目名稱:sym-spectrum,代碼行數:10,代碼來源:field.textarea.php

示例5: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false, $mode)
 {
     if ($mode == null || $mode == 'formatted') {
         if ($this->get('formatter') && isset($data['value_formatted'])) {
             $value = $data['value_formatted'];
         } else {
             $value = $data['value'];
         }
         $value = $this->replaceAmpersands($value);
         $attributes = array('word-count' => General::countWords($value));
         if ($mode == 'formatted') {
             $attributes['mode'] = $mode;
         }
         $wrapper->appendChild(new XMLElement($this->get('element_name'), $encode ? General::sanitize($value) : $value, $attributes));
     } elseif ($mode == 'unformatted') {
         $value = $this->replaceAmpersands($data['value']);
         $wrapper->appendChild(new XMLElement($this->get('element_name'), $encode ? General::sanitize($value) : $value, array('word-count' => General::countWords($value), 'mode' => $mode)));
     }
 }
開發者ID:knupska,項目名稱:symphony-2,代碼行數:19,代碼來源:field.textarea.php


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