Ejemplo n.º 1
0
 /**
  * Returns an array with all available items the Menu gadget 
  * can use
  *
  * @access  public
  * @return  array   URLs array
  */
 function Execute()
 {
     $items = array();
     $items[] = array('url' => $this->gadget->urlMap('DefaultAction'), 'title' => $this->gadget->title);
     $items[] = array('url' => $this->gadget->urlMap('Archive'), 'title' => _t('BLOG_ARCHIVE'));
     $items[] = array('url' => $this->gadget->urlMap('CategoriesList'), 'title' => _t('BLOG_ACTIONS_CATEGORIESLIST'), 'title2' => _t('BLOG_CATEGORIES'));
     $items[] = array('url' => $this->gadget->urlMap('PopularPosts'), 'title' => _t('BLOG_POPULAR_POSTS'));
     $items[] = array('url' => $this->gadget->urlMap('PostsAuthors'), 'title' => _t('BLOG_POSTS_AUTHORS'));
     //Blog model
     $pModel = $this->gadget->model->load('Posts');
     $cModel = $this->gadget->model->load('Categories');
     $categories = $cModel->GetCategories();
     if (!Jaws_Error::IsError($categories)) {
         $max_size = 32;
         foreach ($categories as $cat) {
             $url = $this->gadget->urlMap('ShowCategory', array('id' => empty($cat['fast_url']) ? $cat['id'] : $cat['fast_url']));
             $items[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($cat['name']) > $max_size ? Jaws_UTF8::substr($cat['name'], 0, $max_size) . '...' : $cat['name'], 'acl_key' => 'CategoryAccess', 'acl_subkey' => $cat['id']);
         }
     }
     $entries = $pModel->GetEntries('');
     if (!Jaws_Error::IsError($entries)) {
         $max_size = 32;
         foreach ($entries as $entry) {
             $url = $this->gadget->urlMap('SingleView', array('id' => empty($entry['fast_url']) ? $entry['id'] : $entry['fast_url']));
             $items[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($entry['title']) > $max_size ? Jaws_UTF8::substr($entry['title'], 0, $max_size) . '...' : $entry['title']);
         }
     }
     return $items;
 }
Ejemplo n.º 2
0
 /**
  * Returns an array with all available items the Menu gadget can use
  *
  * @access  public
  * @return  array   List of URLs
  */
 function Execute()
 {
     $urls = array();
     $urls[] = array('url' => $this->gadget->urlMap('Page'), 'title' => $this->gadget->title);
     $urls[] = array('url' => $this->gadget->urlMap('GroupsList'), 'title' => _t('STATICPAGE_GROUPS_LIST'));
     $urls[] = array('url' => $this->gadget->urlMap('PagesTree'), 'title' => _t('STATICPAGE_PAGES_TREE'));
     //Load model
     $max_size = 32;
     $pModel = $this->gadget->model->load('Page');
     $gModel = $this->gadget->model->load('Group');
     $groups = $gModel->GetGroups(true);
     foreach ($groups as $group) {
         if (!$this->gadget->GetPermission('AccessGroup', $group['id'])) {
             continue;
         }
         $url = $this->gadget->urlMap('GroupPages', array('gid' => empty($group['fast_url']) ? $group['id'] : $group['fast_url']));
         $urls[] = array('url' => $url, 'title' => '\\' . $group['title'], 'title2' => Jaws_UTF8::strlen($group['title']) >= $max_size ? Jaws_UTF8::substr($group['title'], 0, $max_size) . '...' : $group['title']);
         $pages = $pModel->GetPages($group['id']);
         foreach ($pages as $page) {
             if ($page['published'] === true) {
                 $url = $this->gadget->urlMap('Pages', array('gid' => empty($group['fast_url']) ? $group['id'] : $group['fast_url'], 'pid' => empty($page['fast_url']) ? $page['base_id'] : $page['fast_url']));
                 $urls[] = array('url' => $url, 'title' => '\\' . $group['title'] . '\\' . $page['title'], 'title2' => Jaws_UTF8::strlen($page['title']) >= $max_size ? Jaws_UTF8::substr($page['title'], 0, $max_size) . '...' : $page['title']);
             }
         }
     }
     return $urls;
 }
Ejemplo n.º 3
0
 /**
  * Returns an array with all available items the Menu gadget 
  * can use
  *
  * @access  public
  * @return  array   URLs array
  */
 function Execute()
 {
     $urls = array();
     $urls[] = array('url' => $this->gadget->urlMap('AlbumList'), 'title' => $this->gadget->title);
     //Load model
     $model = $this->gadget->model->load('Albums');
     $albums = $model->GetAlbums();
     if (!Jaws_Error::IsError($albums) && !empty($albums)) {
         $max_size = 20;
         foreach ($albums as $a) {
             $url = $this->gadget->urlMap('ViewAlbum', array('id' => $a['id']));
             $urls[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($a['name']) > $max_size ? Jaws_UTF8::substr($a['name'], 0, $max_size) . '...' : $a['name']);
         }
     }
     //Load model
     $model = $this->gadget->model->load('Groups');
     $groups = $model->GetGroups();
     if (!Jaws_Error::IsError($groups) && !empty($groups)) {
         $max_size = 20;
         foreach ($groups as $group) {
             $url = $this->gadget->urlMap('AlbumList', array('group' => $group['fast_url']));
             $urls[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($group['name']) > $max_size ? Jaws_UTF8::substr($group['name'], 0, $max_size) . '...' : $group['name']);
         }
     }
     return $urls;
 }
Ejemplo n.º 4
0
 /**
  * Returns an array with all available items the Menu gadget can use
  *
  * @access  public
  * @return  array   List of URLs
  */
 function Execute()
 {
     $urls[] = array('url' => $this->gadget->urlMap('DisplayFeeds'), 'title' => $this->gadget->title);
     $model = $this->gadget->model->load('Feed');
     $feeds = $model->GetFeeds();
     if (!Jaws_Error::isError($feeds)) {
         $max_size = 20;
         foreach ($feeds as $feed) {
             $url = $this->gadget->urlMap('GetFeed', array('id' => $feed['id']));
             $urls[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($feed['title']) > $max_size ? Jaws_UTF8::substr($feed['title'], 0, $max_size) . '...' : $feed['title']);
         }
     }
     return $urls;
 }
Ejemplo n.º 5
0
 /**
  * Returns an array with all available items the Menu gadget 
  * can use
  *
  * @access  public
  * @return  array   URLs array
  */
 function Execute()
 {
     $urls[] = array('url' => $this->gadget->urlMap('Poll'), 'title' => _t('POLL_LAYOUT_LAST'));
     $urls[] = array('url' => $this->gadget->urlMap('Polls'), 'title' => _t('POLL_ACTIONS_POLLS'));
     $model = $this->gadget->model->load('Poll');
     $polls = $model->GetPolls(null, true);
     if (!Jaws_Error::isError($polls)) {
         $max_size = 20;
         foreach ($polls as $poll) {
             $url = $this->gadget->urlMap('ViewPoll', array('id' => $poll['id']));
             $urls[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($poll['question']) > $max_size ? Jaws_UTF8::substr($poll['question'], 0, $max_size) . '...' : $poll['question']);
         }
     }
     return $urls;
 }
Ejemplo n.º 6
0
 /**
  * Returns an array with all available items the Menu gadget can use
  *
  * @access  public
  * @return  array   List of URLs
  */
 function Execute()
 {
     $urls = array();
     $urls[] = array('url' => $this->gadget->urlMap('RecentQuotes'), 'title' => $this->gadget->title);
     $model = $this->gadget->model->load('Groups');
     $groups = $model->GetGroups();
     if (!Jaws_Error::isError($groups)) {
         $max_size = 20;
         foreach ($groups as $group) {
             $url = $this->gadget->urlMap('ViewGroupQuotes', array('id' => $group['id']));
             $urls[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($group['title']) > $max_size ? Jaws_UTF8::substr($group['title'], 0, $max_size) . '...' : $group['title']);
         }
     }
     return $urls;
 }
Ejemplo n.º 7
0
 /**
  * Returns an array with all available items the Menu gadget 
  * can use
  *
  * @access  public
  * @return  array   URLs array
  */
 function Execute()
 {
     $urls = array();
     //Blocks model
     $model = $this->gadget->model->load('Block');
     $blocks = $model->GetBlocks(true);
     if (!Jaws_Error::IsError($blocks)) {
         $max_size = 20;
         foreach ($blocks as $block) {
             $url = $this->gadget->urlMap('Block', array('id' => $block['id']));
             $urls[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($block['title']) > $max_size ? Jaws_UTF8::substr($block['title'], 0, $max_size) . '...' : $block['title']);
         }
     }
     return $urls;
 }
Ejemplo n.º 8
0
 /**
  * Returns an array with all available items the Menu gadget 
  * can use
  *
  * @access  public
  * @return  array   URLs array
  */
 function Execute()
 {
     $urls = array();
     $urls[] = array('url' => $this->gadget->urlMap('View'), 'title' => $this->gadget->title);
     //Load model
     $model = $this->gadget->model->load('Category');
     $categories = $model->GetCategories();
     if (!Jaws_Error::isError($categories)) {
         $max_size = 20;
         foreach ($categories as $category) {
             $url = $this->gadget->urlMap('ViewCategory', array('id' => $category['id']));
             $urls[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($category['category']) > $max_size ? Jaws_UTF8::substr($category['category'], 0, $max_size) . '...' : $category['category']);
         }
     }
     return $urls;
 }
Ejemplo n.º 9
0
 /**
  * Returns an array with all available items the Menu gadget 
  * can use
  *
  * @access  public
  * @return  array   URLs array
  */
 function Execute()
 {
     $urls[] = array('url' => $this->gadget->urlMap('Categories'), 'title' => $this->gadget->title);
     $model = $this->gadget->model->load('Groups');
     $groups = $model->GetGroups();
     if (!Jaws_Error::IsError($groups)) {
         $max_size = 32;
         foreach ($groups as $group) {
             $title = _t('LINKDUMP_LINKS_ARCHIVE') . ' - ' . $group['title'];
             $gid = empty($group['fast_url']) ? $group['id'] : $group['fast_url'];
             $url = $this->gadget->urlMap('Category', array('id' => $gid));
             $urls[] = array('url' => $url, 'title' => Jaws_UTF8::strlen($title) > $max_size ? Jaws_UTF8::substr($title, 0, $max_size - 3) . '...' : $title);
         }
     }
     return $urls;
 }
Ejemplo n.º 10
0
 function Get($email, $name)
 {
     $code = '<a  href="' . $this->encText('mailto:', true) . $this->encText($email, true) . '">' . $name . '</a>';
     $javacode = '<script language="JavaScript" type="text/JavaScript">';
     $i = 0;
     $code_l = Jaws_UTF8::strlen($code);
     while ($i < $code_l) {
         //get next part of code with random length from 15 to 20
         $len = rand(15, 20);
         if ($i + $len > $code_l) {
             $len = $code_l - $i;
         }
         $part = Jaws_UTF8::substr($code, $i, $len);
         $javacode .= "document.write('{$part}');";
         $i += $len;
     }
     $javacode .= "</script>";
     return $javacode;
 }
Ejemplo n.º 11
0
 /**
  * Save changes on an edited blog entry and shows the entries list on admin section
  *
  * @access  public
  */
 function SaveEditEntry()
 {
     $names = array('id', 'edit_timestamp:array', 'pubdate', 'categories:array', 'title', 'fasturl', 'meta_keywords', 'meta_desc', 'tags', 'deleteImage', 'allow_comments:array', 'published', 'trackback_to');
     $post = jaws()->request->fetch($names, 'post');
     $content = jaws()->request->fetch(array('summary_block', 'text_block'), 'post', 'strip_crlf');
     $post['trackback_to'] = str_replace("\r\n", "\n", $post['trackback_to']);
     $pModel = $this->gadget->model->loadAdmin('Posts');
     $tModel = $this->gadget->model->loadAdmin('Trackbacks');
     $id = (int) $post['id'];
     $pubdate = null;
     if (isset($post['edit_timestamp']) && $post['edit_timestamp'][0] == 'yes') {
         $pubdate = $post['pubdate'];
     }
     $post['categories'] = !empty($post['categories']) ? $post['categories'] : array();
     foreach ($post['categories'] as $cat) {
         if (!$this->gadget->GetPermission('CategoryManage', $cat)) {
             return Jaws_HTTPError::Get(403);
         }
     }
     // Upload blog image
     $image = false;
     if ($post['deleteImage'] == 'false') {
         $image = null;
         if (count($_FILES) > 0 && !empty($_FILES['image_file']['name'])) {
             $targetDir = JAWS_DATA . 'blog' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR;
             $res = Jaws_Utils::UploadFiles($_FILES, $targetDir, 'jpg,gif,png,jpeg,bmp', false);
             if (Jaws_Error::IsError($res)) {
                 $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
             } elseif (empty($res)) {
                 $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_UPLOAD_4'), RESPONSE_ERROR);
             } else {
                 $image = $res['image_file'][0]['host_filename'];
                 // Delete old image
                 $model = $this->gadget->model->load('Posts');
                 $blogEntry = $model->GetEntry($id);
                 if (!empty($blogEntry['image'])) {
                     Jaws_Utils::Delete($targetDir . $blogEntry['image']);
                 }
             }
         }
     } else {
         // Delete old image
         $model = $this->gadget->model->load('Posts');
         $blogEntry = $model->GetEntry($id);
         if (!empty($blogEntry['image'])) {
             $targetDir = JAWS_DATA . 'blog' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR;
             Jaws_Utils::Delete($targetDir . $blogEntry['image']);
         }
     }
     $pModel->UpdateEntry($id, $post['categories'], $post['title'], $content['summary_block'], $content['text_block'], $image, $post['fasturl'], $post['meta_keywords'], $post['meta_desc'], $post['tags'], isset($post['allow_comments'][0]), $post['trackback_to'], $post['published'], $pubdate);
     if (!Jaws_Error::IsError($id)) {
         if ($this->gadget->registry->fetch('trackback') == 'true') {
             $to = explode("\n", $post['trackback_to']);
             $link = $this->gadget->urlMap('SingleView', array('id' => $id), true);
             $title = $post['title'];
             $text = $content['text_block'];
             if (Jaws_UTF8::strlen($text) > 250) {
                 $text = Jaws_UTF8::substr($text, 0, 250) . '...';
             }
             $tModel->SendTrackback($title, $text, $link, $to);
         }
     }
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=EditEntry&id=' . $id);
 }
Ejemplo n.º 12
0
Archivo: Feeds.php Proyecto: uda/jaws
 /**
  * Create ATOM struct of recent comments
  *
  * @access  private
  * @param   string  $gadget     Gadget name
  * @param   string  $action     Action name
  * @param   int     $reference  Reference Id
  * @param   string  $feed_type feed type
  * @return  object  Can return the Atom Object
  */
 function GetRecentCommentsAtomStruct($gadget, $action = null, $reference = null, $feed_type = 'atom')
 {
     $max_title_size = 80;
     $cModel = $this->gadget->model->load('Comments');
     $comments = $cModel->GetComments($gadget, $action, $reference, '', array(Comments_Info::COMMENTS_STATUS_APPROVED));
     if (Jaws_Error::IsError($comments)) {
         return new Jaws_Error(_t('COMMENTS_ERROR_GETTING_COMMENTS_ATOMSTRUCT'));
     }
     $commentAtom = new Jaws_AtomFeed();
     $siteURL = $GLOBALS['app']->GetSiteURL('/');
     $params = array('gadgetname' => $gadget);
     if (!empty($action)) {
         $params['actionname'] = $action;
     }
     if (!empty($reference)) {
         $params['reference'] = $reference;
     }
     $url = $this->gadget->urlMap($feed_type == 'atom' ? 'RecentCommentsAtom' : 'RecentCommentsRSS', $params, true);
     $commentAtom->SetTitle($this->gadget->registry->fetch('site_name', 'Settings'));
     $commentAtom->SetLink($url);
     $commentAtom->SetId($siteURL);
     $commentAtom->SetAuthor($this->gadget->registry->fetch('site_author', 'Settings'), $GLOBALS['app']->GetSiteURL('/'), $this->gadget->registry->fetch('gate_email', 'Settings'));
     $commentAtom->SetGenerator('JAWS ' . $GLOBALS['app']->Registry->fetch('version'));
     $commentAtom->SetCopyright($this->gadget->registry->fetch('site_copyright', 'Settings'));
     $commentAtom->SetTagLine(_t('COMMENTS_RECENT_COMMENTS', _t(strtoupper($gadget) . '_TITLE')));
     $objDate = Jaws_Date::getInstance();
     $site = preg_replace('/(.*)\\/.*/i', '\\1', $commentAtom->Link->HRef);
     foreach ($comments as $c) {
         $entry_id = $c['reference'];
         $entry = new AtomEntry();
         $entry->SetTitle(Jaws_UTF8::strlen($c['msg_txt']) >= $max_title_size ? Jaws_UTF8::substr($c['msg_txt'], 0, $max_title_size) . '...' : $c['msg_txt']);
         $entry->SetId("urn:gadget:{$gadget}:action:{$action}:reference:{$reference}:comment:{$c['id']}");
         switch ($gadget) {
             case 'Blog':
                 // So we can use the UrlMapping feature.
                 $url = $GLOBALS['app']->Map->GetURLFor('Blog', 'SingleView', array('id' => $entry_id), true);
                 $url = $url . htmlentities('#comment' . $c['id']);
                 $entry->SetLink($url);
                 break;
             case 'Phoo':
                 $url = $GLOBALS['app']->Map->GetURLFor('Phoo', 'ViewImage', array('id' => $entry_id), true);
                 $url = $url . htmlentities('#comment' . $c['id']);
                 $entry->SetLink($url);
                 break;
             case 'Shoutbox':
                 $url = $GLOBALS['app']->Map->GetURLFor('Shoutbox', 'Comments', array(), true);
                 $url = $url . htmlentities('#comment' . $c['id']);
                 $entry->SetLink($url);
                 break;
         }
         $content = Jaws_String::AutoParagraph($c['msg_txt']);
         $entry->SetSummary($content, 'html');
         $entry->SetContent($content, 'html');
         $entry->SetAuthor($c['name'], $commentAtom->Link->HRef, $c['email']);
         $entry->SetPublished($objDate->ToISO($c['insert_time']));
         $entry->SetUpdated($objDate->ToISO($c['insert_time']));
         $commentAtom->AddEntry($entry);
         if (!isset($last_modified)) {
             $last_modified = $c['insert_time'];
         }
     }
     if (isset($last_modified)) {
         $commentAtom->SetUpdated($objDate->ToISO($last_modified));
     } else {
         $commentAtom->SetUpdated($objDate->ToISO(date('Y-m-d H:i:s')));
     }
     return $commentAtom;
 }
Ejemplo n.º 13
0
 /**
  * Displays a block of pages belongs to the specified group
  *
  * @access  public
  * @param   string  $gadget          Gadget name
  * @param   string  $action          Gadget action
  * @param   int     $reference
  * @param   array   $pagination_data
  * @param   int     $user           User Id
  * @param   int     $perPage
  * @param   int     $orderBy
  * @internal param string $gadget
  * @internal param mixed $limit limit recent comments (int)
  * @return  string  XHTML content
  */
 function ShowComments($gadget, $action, $reference, $pagination_data, $user = null, $perPage = null, $orderBy = 0)
 {
     $max_size = 52;
     $compactView = $GLOBALS['app']->requestedActionMode == ACTION_MODE_LAYOUT;
     $rqst = jaws()->request->fetch(array('order', 'page'), 'get');
     $page = empty($rqst['page']) ? 1 : (int) $rqst['page'];
     if ($GLOBALS['app']->requestedActionMode == ACTION_MODE_NORMAL && !empty($rqst['order'])) {
         $orderBy = (int) $rqst['order'];
     }
     if (empty($perPage)) {
         $perPage = $this->gadget->registry->fetch('comments_per_page');
     }
     $cModel = $this->gadget->model->load('Comments');
     $comments = $cModel->GetComments($gadget, $action, $reference, '', Comments_Info::COMMENTS_STATUS_APPROVED, $perPage, ($page - 1) * $perPage, $orderBy, $user);
     $comments_count = $cModel->GetCommentsCount($gadget, $action, $reference, '', '', $user);
     $tpl = $this->gadget->template->load('Comments.html');
     $block = 'comments';
     if ($compactView == true) {
         $block = 'comments_compact';
     }
     $tpl->SetBlock($block);
     $tpl->SetVariable('title', _t('COMMENTS_COMMENTS'));
     $tpl->SetVariable('gadget', strtolower($gadget));
     $objDate = Jaws_Date::getInstance();
     $usrModel = new Jaws_User();
     if (!Jaws_Error::IsError($comments) && $comments != null) {
         foreach ($comments as $entry) {
             $tpl->SetBlock($block . '/entry');
             $tpl->SetVariable('postedby_lbl', _t('COMMENTS_POSTEDBY'));
             if ($entry['user_registered_date']) {
                 $tpl->SetBlock($block . '/entry/registered_date');
                 $tpl->SetVariable('registered_date_lbl', _t('COMMENTS_USERS_REGISTERED_DATE'));
                 $tpl->SetVariable('registered_date', $objDate->Format($entry['user_registered_date'], 'd MN Y'));
                 $tpl->ParseBlock($block . '/entry/registered_date');
             }
             if (!empty($entry['username'])) {
                 // user's profile
                 $tpl->SetVariable('user_url', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $entry['username'])));
             } else {
                 $tpl->SetVariable('user_url', Jaws_XSS::filter($entry['url']));
             }
             $nickname = empty($entry['nickname']) ? $entry['name'] : $entry['nickname'];
             $email = empty($entry['user_email']) ? $entry['email'] : $entry['user_email'];
             $tpl->SetVariable('nickname', Jaws_XSS::filter($nickname));
             $tpl->SetVariable('email', Jaws_XSS::filter($email));
             $tpl->SetVariable('username', Jaws_XSS::filter($entry['username']));
             // user's avatar
             $tpl->SetVariable('avatar', $usrModel->GetAvatar($entry['avatar'], $entry['email'], 80));
             $tpl->SetVariable('insert_time', $objDate->Format($entry['createtime']));
             $tpl->SetVariable('insert_time_iso', $objDate->ToISO($entry['createtime']));
             $tpl->SetVariable('message', $this->gadget->ParseText($entry['msg_txt'], 'Comments', 'index'));
             $tpl->SetVariable('message_abbr', Jaws_UTF8::strlen($entry['msg_txt']) >= $max_size ? Jaws_UTF8::substr($entry['msg_txt'], 0, $max_size) . '...' : $entry['msg_txt']);
             if (Jaws_UTF8::strlen($entry['msg_txt']) >= $max_size) {
                 $tpl->SetBlock($block . '/entry/read_more');
                 $tpl->SetVariable('read_more', _t('COMMENTS_READ_MORE'));
                 switch ($entry['gadget']) {
                     case 'Blog':
                         $url = $GLOBALS['app']->Map->GetURLFor('Blog', 'SingleView', array('id' => $entry['reference']), true);
                         $url = $url . '#comment' . $entry['id'];
                         break;
                     case 'Phoo':
                         $url = $GLOBALS['app']->Map->GetURLFor('Phoo', 'ViewImage', array('id' => $entry['reference']), true);
                         $url = $url . '#comment' . $entry['id'];
                         break;
                     case 'Shoutbox':
                         $url = $GLOBALS['app']->Map->GetURLFor('Shoutbox', 'Comments', array(), true);
                         $url = $url . '#comment' . $entry['id'];
                         break;
                     case 'Comments':
                         $url = $GLOBALS['app']->Map->GetURLFor('Comments', 'Guestbook', array(), true);
                         $url = $url . '#comment' . $entry['id'];
                         break;
                     default:
                         $url = '';
                 }
                 $tpl->SetVariable('read_more_url', $url);
                 $tpl->ParseBlock($block . '/entry/read_more');
             }
             if (!empty($entry['reply'])) {
                 $tpl->SetBlock($block . '/entry/reply');
                 $tpl->SetVariable('lbl_replier', _t('COMMENTS_REPLIER'));
                 $tpl->SetVariable('replier', $entry['replier_nickname']);
                 // user's profile
                 $tpl->SetVariable('replier_url', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $entry['replier_username'])));
                 $tpl->SetVariable('reply', $entry['reply']);
                 $tpl->ParseBlock($block . '/entry/reply');
             }
             $reply_url =& Piwi::CreateWidget('Link', _t('COMMENTS_REPLY_TO_COMMENT'), 'javascript:replyComment();');
             $tpl->SetVariable('reply-link', $reply_url->Get());
             $tpl->ParseBlock($block . '/entry');
         }
     }
     if (!$compactView) {
         $pagination_data['params']['order'] = $orderBy;
         // page navigation
         $this->GetPagesNavigation($tpl, 'comments', $page, $perPage, $comments_count, _t('COMMENTS_COMMENTS_COUNT', $comments_count), $gadget, $pagination_data['action'], $pagination_data['params']);
         // feeds actions
         $tpl->SetVariable('lbl_feeds', _t('COMMENTS_COMMENTS_XML'));
         $tpl->SetVariable('atom_url', $this->gadget->urlMap('RecentCommentsAtom', array('gadgetname' => $gadget, 'actionname' => $action, 'reference' => $reference)));
         $tpl->SetVariable('rss_url', $this->gadget->urlMap('RecentCommentsRSS', array('gadgetname' => $gadget, 'actionname' => $action, 'reference' => $reference)));
     }
     $tpl->ParseBlock($block);
     return $tpl->Get();
 }
Ejemplo n.º 14
0
 /**
  * Build a new array with filtered data
  *
  * @access  public
  * @param   string  $requester  Requester gadget name
  * @param   string  $gadget     Gadget name
  * @param   string  $term       Search term
  * @param   int     $status     Spam status (approved=1, waiting=2, spam=3)
  * @param   mixed   $offset     Data offset (numeric/boolean)
  * @param   int     $orderBy    Data order
  * @return  array   Filtered Comments
  */
 function GetDataAsArray($requester, $gadget, $term, $status, $offset, $orderBy)
 {
     $data = array();
     $cModel = $this->gadget->model->load('Comments');
     $comments = $cModel->GetComments($gadget, '', '', $term, $status, 15, $offset, $orderBy);
     if (Jaws_Error::IsError($comments)) {
         return $data;
     }
     $date = Jaws_Date::getInstance();
     $data = array();
     foreach ($comments as $row) {
         $newRow = array();
         $newRow['__KEY__'] = $row['id'];
         if ($requester == $this->gadget->name) {
             $newRow['gadget'] = _t(strtoupper($row['gadget']) . '_TITLE');
         }
         $comment = Jaws_UTF8::strlen($row['msg_txt']) > 25 ? Jaws_UTF8::substr($row['msg_txt'], 0, 22) . '...' : $row['msg_txt'];
         $comment = "<abbr title='" . $row['msg_txt'] . "'>{$comment}</abbr>";
         $link =& Piwi::CreateWidget('Link', $comment, "javascript:editComment(this, '{$row['id']}');");
         $newRow['comment'] = $link->Get();
         $newRow['name'] = $row['name'];
         $newRow['created'] = $date->Format($row['insert_time']);
         if ($row['status'] == Comments_Info::COMMENTS_STATUS_APPROVED) {
             $status = _t('COMMENTS_STATUS_APPROVED');
         } elseif ($row['status'] == Comments_Info::COMMENTS_STATUS_WAITING) {
             $status = _t('COMMENTS_STATUS_WAITING');
         } elseif ($row['status'] == Comments_Info::COMMENTS_STATUS_SPAM) {
             $status = _t('COMMENTS_STATUS_SPAM');
         } elseif ($row['status'] == Comments_Info::COMMENTS_STATUS_PRIVATE) {
             $status = _t('COMMENTS_STATUS_PRIVATE');
         }
         $newRow['status'] = $status;
         $data[] = $newRow;
     }
     return $data;
 }
Ejemplo n.º 15
0
 /**
  * Find length of initial segment matching mask
  * @see http://www.php.net/strspn
  */
 static function strspn($str, $mask, $start = null, $length = null)
 {
     $mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\\${1}', $mask);
     if ($start !== null || $length !== null) {
         $str = Jaws_UTF8::substr($str, $start, $length);
     }
     preg_match('/^[' . $mask . ']+/u', $str, $matches);
     if (isset($matches[0])) {
         return Jaws_UTF8::strlen($matches[0]);
     }
     return 0;
 }
Ejemplo n.º 16
0
 /**
  * Parses a search phrase to find the excluding matches, exact matches,
  * any matches and all other words
  *
  * @access  public
  * @param   string  $phrase     Phrase to parse
  * @param   array   $searchable List of searchable gadgets
  * @return  array   An array with the following indexes (and results):
  *                     - all, exact, least and exclude
  */
 function parseSearch($options, &$searchable)
 {
     $phrase = $options['all'];
     if (!empty($phrase)) {
         $phrase .= chr(32);
     }
     $newOptions = array('all' => '', 'exact' => '', 'least' => '', 'exclude' => '', 'date' => '');
     $size = Jaws_UTF8::strlen($phrase);
     $lastKey = '';
     $tmpWord = '';
     for ($i = 0; $i < $size; $i++) {
         $word = Jaws_UTF8::substr($phrase, $i, 1);
         $ord = Jaws_UTF8::ord($word);
         $tmpWord .= $word;
         switch ($ord) {
             case 34:
                 // Quotes..
                 if ($lastKey == 'exact') {
                     //Open exact was open, we are closing it
                     $newOptions['exact'] .= Jaws_UTF8::substr($tmpWord, 1, Jaws_UTF8::strlen($tmpWord) - 2);
                     $lastKey = '';
                     $tmpWord = '';
                 } else {
                     if (empty($lastKey)) {
                         $lastKey = 'exact';
                         //We open the exact match
                     }
                 }
                 break;
             case 43:
                 //Plus
                 if ($lastKey != 'exact') {
                     $lastKey = 'least';
                 }
                 break;
             case 45:
                 //Minus
                 if ($lastKey != 'exclude') {
                     $lastKey = 'exclude';
                 }
                 break;
             case 32:
                 //Space
                 if ($lastKey != 'exact' && !empty($lastKey)) {
                     if ($lastKey != 'all') {
                         $substrCount = 1;
                         if ($tmpWord[0] == ' ') {
                             $substrCount = 2;
                         }
                         $newOptions[$lastKey] .= Jaws_UTF8::substr($tmpWord, $substrCount);
                     } else {
                         $newOptions[$lastKey] .= $tmpWord;
                     }
                     $lastKey = '';
                     $tmpWord = '';
                 }
                 break;
             default:
                 //Any other word opens all
                 if (empty($lastKey)) {
                     $lastKey = 'all';
                 }
                 break;
         }
     }
     $options['all'] = '';
     $min_key_len = $this->gadget->registry->fetch('min_key_len');
     foreach (array_keys($newOptions) as $option) {
         if (!empty($newOptions[$option])) {
             $options[$option] = trim(isset($options[$option]) ? $options[$option] . ' ' . $newOptions[$option] : $newOptions[$option]);
         }
         $content = isset($options[$option]) ? $options[$option] : '';
         $content = $content;
         $content = Jaws_UTF8::strtolower(Jaws_UTF8::trim($content));
         if (Jaws_UTF8::strlen($content) >= $min_key_len) {
             $searchable = true;
         }
         $options[$option] = '';
         switch ($option) {
             case 'exclude':
             case 'least':
             case 'all':
                 $options[$option] = array_filter(explode(' ', $content));
                 break;
             case 'exact':
                 $options[$option] = array($content);
                 break;
             case 'date':
                 if (in_array($content, array('past_1month', 'past_2month', 'past_3month', 'past_6month', 'past_1year', 'anytime'))) {
                     $options[$option] = array($content);
                 } else {
                     $options[$option] = array('anytime');
                 }
                 break;
         }
     }
     return $options;
 }