Example #1
0
 public function getLikePages($pagename)
 {
     if (Horde_String::isUpper($pagename, 'UTF-8')) {
         $firstword = $pagename;
         $lastword = null;
     } else {
         /* Get the first and last word of the page name. */
         $count = preg_match_all('/[A-Z][a-z0-9]*/', $pagename, $matches);
         if (!$count) {
             return array();
         }
         $matches = $matches[0];
         $firstword = $matches[0];
         $lastword = $matches[$count - 1];
         if (strlen($firstword) == 1 && strlen($matches[1]) == 1) {
             for ($i = 1; $i < $count; $i++) {
                 $firstword .= $matches[$i];
                 if (isset($matches[$i + 1]) && strlen($matches[$i + 1]) > 1) {
                     break;
                 }
             }
         }
         if (strlen($lastword) == 1 && strlen($matches[$count - 2]) == 1) {
             for ($i = $count - 2; $i > 0; $i--) {
                 $lastword = $matches[$i] . $lastword;
                 if (isset($matches[$i - 1]) && strlen($matches[$i - 1]) > 1) {
                     break;
                 }
             }
         }
     }
     try {
         $where = $this->_db->buildClause('page_name', 'LIKE', $firstword);
         if (!empty($lastword) && $lastword != $firstword) {
             $where .= ' OR ' . $this->_db->buildClause('page_name', 'LIKE', $lastword);
         }
     } catch (Horde_Db_Exception $e) {
         throw new Wicked_Exception($e);
     }
     return $this->_retrieve($this->_params['table'], $where);
 }