public function getDescription() { // Remove bbcode $desc = strip_tags($this->body); $desc = preg_replace('/\\[[^\\[\\]]+?\\]/', '', $desc); return Engine_String::substr($desc, 0, 255); }
public function getDescription() { // strip HTML and BBcode $content = strip_tags($this->body); $content = preg_replace('|[[\\/\\!]*?[^\\[\\]]*?]|si', '', $content); return Engine_String::strlen($content) > 255 ? Engine_String::substr($content, 0, 255) . '...' : $content; }
public function getDescription() { $firstPost = $this->getFirstPost(); if (null !== $firstPost) { $content = strip_tags($firstPost->body); return Engine_String::substr($content, 0, 255); } return ''; }
public function getDescription() { $firstPost = $this->getFirstPost(); $content = ''; if (null !== $firstPost) { $content = $firstPost->body; // strip HTML and BBcode $content = strip_tags($content); $content = preg_replace('|[[\\/\\!]*?[^\\[\\]]*?]|si', '', $content); $content = Engine_String::strlen($content) > 255 ? Engine_String::substr($content, 0, 255) . '...' : $content; } return $content; }
public function getRichContent($view = false, $params = array()) { // if video type is youtube if ($this->type == 1) { $videoEmbedded = $this->compileYouTube($this->code, $view); } // if video type is vimeo if ($this->type == 2) { $videoEmbedded = $this->compileVimeo($this->code, $view); } // if video type is uploaded if ($this->type == 3) { $video_location = Engine_Api::_()->storage()->get($this->file_id, $this->getType())->getHref(); $videoEmbedded = $this->compileFlowPlayer($video_location, $view); } // $view == false means that this rich content is requested from the activity feed if ($view == false) { // prepare the duration // $video_duration = ""; if ($this->duration) { if ($this->duration > 360) { $duration = gmdate("H:i:s", $this->duration); } else { $duration = gmdate("i:s", $this->duration); } if ($duration[0] == '0') { $duration = substr($duration, 1); } $video_duration = "<span class='video_length'>" . $duration . "</span>"; } // prepare the thumbnaile $thumb = Zend_Registry::get('Zend_View')->itemPhoto($this, 'thumb.video.activity'); if ($this->photo_id) { $thumb = Zend_Registry::get('Zend_View')->itemPhoto($this, 'thumb.video.activity'); } else { $thumb = '<img alt="" src="application/modules/Video/externals/images/video.png">'; } $thumb = '<a id="video_thumb_' . $this->video_id . '" style="" href="javascript:void(0);" onclick="javascript:var myElement = $(this);myElement.style.display=\'none\';var next = myElement.getNext(); next.style.display=\'block\';"> <div class="video_thumb_wrapper">' . $video_duration . $thumb . '</div> </a>'; // prepare title and description $title = "<a href='" . $this->getHref($params) . "'>{$this->title}</a>"; $tmpBody = strip_tags($this->description); $description = "<div class='video_desc'>" . (Engine_String::strlen($tmpBody) > 255 ? Engine_String::substr($tmpBody, 0, 255) . '...' : $tmpBody) . "</div>"; $videoEmbedded = $thumb . '<div id="video_object_' . $this->video_id . '" style="display:none;">' . $videoEmbedded . '</div><div class="video_info">' . $title . $description . '</div>'; } return $videoEmbedded; }
public function getRichContent($view = false, $params = array()) { $playlist = $this->getParent(); $videoEmbedded = ''; // $view == false means that this rich content is requested from the activity feed if ($view == false) { $desc = strip_tags($playlist->description); $desc = "<div class='music_desc'>" . (Engine_String::strlen($desc) > 255 ? Engine_String::substr($desc, 0, 255) . '...' : $desc) . "</div>"; $zview = Zend_Registry::get('Zend_View'); $zview->playlist = $playlist; $zview->songs = array($this); $zview->short_player = true; $videoEmbedded = $desc . $zview->render('application/modules/Music/views/scripts/_Player.tpl'); } return $videoEmbedded; }
public function getSlug($str = NULL, $maxstrlen = 64) { $str = $this->getTitle(); if (strlen($str) > 32) { $str = Engine_String::substr($str, 0, 32) . '...'; } $str = preg_replace('/([a-z])([A-Z])/', '$1 $2', $str); $str = strtolower($str); $str = preg_replace('/[^a-z0-9-]+/i', '-', $str); $str = preg_replace('/-+/', '-', $str); $str = trim($str, '-'); if (!$str) { $str = '-'; } return $str; }
public function getRichContent($view = false, $params = array()) { $videoEmbedded = ''; // $view == false means that this rich content is requested from the activity feed if ($view == false) { $desc = strip_tags($this->description); $desc = "<div class='music_desc'>" . (Engine_String::strlen($desc) > 255 ? Engine_String::substr($desc, 0, 255) . '...' : $desc) . "</div>"; $zview = Zend_Registry::get('Zend_View'); $zview->playlist = $this; $zview->songs = $this->getSongs(); $zview->short_player = true; $videoEmbedded = $desc . $zview->render('application/modules/Music/views/scripts/_Player.tpl'); } // hide playlist if in production mode if (!count($zview->songs) && 'production' == APPLICATION_ENV) { throw new Exception('Empty playlists show not be shown'); } return $videoEmbedded; }
public function viewMore($string, $moreLength = null, $maxLength = null) { if (!is_numeric($moreLength) || $moreLength <= 0) { $moreLength = $this->_moreLength; } if (!is_numeric($maxLength) || $maxLength <= 0) { $maxLength = $this->_maxLength; } if (Engine_String::strlen($string) <= $moreLength + $this->_fudgesicles) { return $string; } if (Engine_String::strlen($string) >= $maxLength) { $string = Engine_String::substr($string, 0, $maxLength) . $this->view->translate('... '); } //$id = $this->_prefix . '_' . self::$_index++; //$class = $this->_prefix; $content = ''; $content .= '<' . $this->_tag . ' class="view_more"' . '>' . Engine_String::substr($string, 0, $moreLength) . $this->view->translate('... ') . '<a class="view_more_link" href="javascript:void(0);" onclick="$(this).getParent().getNext().style.display=\'\';$(this).getParent().style.display=\'none\';">' . $this->view->translate('more') . '</a>' . '</' . $this->_tag . '>' . '<' . $this->_tag . ' class="view_more"' . ' style="display:none;"' . '>' . $string . ' ' . '<a class="view_less_link" href="javascript:void(0);" onclick="$(this).getParent().getPrevious().style.display=\'\';$(this).getParent().style.display=\'none\';">' . $this->view->translate('less') . '</a>' . '</' . $this->_tag . '>'; return $content; }
public function filter($value) { return Engine_String::substr($value, 0, $this->_maxLength); }
public function getDescription() { return Engine_String::substr($this->body, 0, 255); }
public function whisperAction() { $userTable = Engine_Api::_()->getDbtable('users', 'chat'); // Check viewer $viewer = Engine_Api::_()->user()->getViewer(); if (!$viewer->getIdentity()) { $this->view->status = false; $this->view->error = true; $this->view->message = 'AUTH_FAIL'; return; } // Check for chat user $userTable->check($viewer); // Check for target user $targetUserId = (int) $this->_getParam('user_id'); $targetUser = $userTable->find($targetUserId)->current(); if (null === $targetUser) { $this->view->status = false; $this->view->error = true; $this->view->message = 'NOT_ONLINE'; return; } // Rate limiting $session = $this->getSession(); // Clear out old if (!isset($session->whisperRate) || !is_array($session->whisperRate)) { $session->whisperRate = array(); } foreach ($session->whisperRate as $index => $time) { if (time() > $time + 5) { unset($session->whisperRate[$index]); } } // Check count $rate = count($session->whisperRate); if ($rate > 10) { $this->view->status = false; $this->view->error = true; $this->view->message = 'RATE_LIMIT_EXCEEDED'; return; } // Do it! $censor = new Engine_Filter_Censor(); $message = $censor->filter($this->_getParam('message')); $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); $message = htmlspecialchars($message, ENT_NOQUOTES, 'UTF-8'); if (Engine_String::strlen($message) > 1023) { $message = Engine_String::substr($message, 0, 1023); } // Start transaction $db = $userTable->getAdapter(); $db->beginTransaction(); try { // Send message $whisperObject = $targetUser->whisper($viewer, $message); $session->whisperRate[] = time(); $db->commit(); $this->view->status = true; $this->view->error = false; $this->view->whisper_id = $whisperObject->whisper_id; } catch (Exception $e) { $db->rollBack(); $this->view->status = false; $this->view->error = true; $this->view->message = 'ERROR'; if (APPLICATION_ENV === 'development') { $this->view->error_message = $e->__toString(); } } }
public function truncate($string, $length = 300, $chopString = null) { if (Engine_String::strlen($string) <= $length) { return $string; } if (null === $chopString) { $chopString = '...'; } $chopString = $this->view->translate($chopString); return Engine_String::substr($string, 0, $length) . $chopString; }
public function getDescription() { $firstPost = $this->getFirstPost(); return null !== $firstPost ? Engine_String::substr($firstPost->body, 0, 255) : ''; }
public function getRichContent($view = false, $params = array()) { $session = new Zend_Session_Namespace('mobile'); $mobile = $session -> mobile; $count_video = 0; if (isset($session -> count)) $count_video = ++$session -> count; $paramsForCompile = array_merge(array( 'video_id' => $this -> video_id, 'code' => $this -> code, 'view' => $view, 'mobile' => $mobile, 'duration' => $this -> duration, 'count_video' => $count_video ), $params); if ($this -> type == Ynvideo_Plugin_Factory::getUploadedType()) { $responsive_mobile = FALSE; if (defined('YNRESPONSIVE')) { $responsive_mobile = Engine_Api::_() -> ynresponsive1() -> isMobile(); } if (!empty($this -> file1_id)) { $storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file_id); if ($session -> mobile || $responsive_mobile) { $storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file1_id); } if ($storage_file) { $paramsForCompile['location1'] = $storage_file -> getHref(); $paramsForCompile['location'] = ''; } } else { $storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file_id); if ($storage_file) { $paramsForCompile['location'] = $storage_file -> getHref(); $paramsForCompile['location1'] = ''; } } } else if ($this -> type == Ynvideo_Plugin_Factory::getVideoURLType()) { $paramsForCompile['location'] = $this -> code; } $videoEmbedded = Ynvideo_Plugin_Factory::getPlugin((int)$this -> type) -> compileVideo($paramsForCompile); // $view == false means that this rich content is requested from the activity feed if ($view == false) { $video_duration = ""; if ($this -> duration) { if ($this -> duration >= 3600) { $duration = gmdate("H:i:s", $this -> duration); } else { $duration = gmdate("i:s", $this -> duration); } $video_duration = "<span class='video_length'>" . $duration . "</span>"; } // prepare the thumbnail $thumb = Zend_Registry::get('Zend_View') -> itemPhoto($this, 'thumb.large'); if ($this -> photo_id) { $thumb = Zend_Registry::get('Zend_View') -> itemPhoto($this, 'thumb.large'); } else { $thumb = '<img alt="" src="' . Zend_Registry::get('StaticBaseUrl') . 'application/modules/Video/externals/images/video.png">'; } if (!$mobile) { $thumb = '<a id="video_thumb_' . $this -> video_id . $count_video . '" style="" href="javascript:void(0);" onclick="javascript:var myElement = $(this);myElement.style.display=\'none\';var next = myElement.getNext(); next.style.display=\'block\';"> <div class="video_thumb_wrapper">' . $video_duration . $thumb . '</div> </a>'; } else { $thumb = '<a id="video_thumb_' . $this -> video_id . $count_video . '" class="video_thumb" href="javascript:void(0);"> <div class="video_thumb_wrapper">' . $video_duration . $thumb . '</div> </a>'; } // prepare title and description $title = "<a class='smoothbox' href='" . $this -> getPopupHref($params) . "'>". $this-> getTitle()."</a>"; $tmpBody = strip_tags($this -> description); $description = "<div class='video_desc'>" . (Engine_String::strlen($tmpBody) > 255 ? Engine_String::substr($tmpBody, 0, 255) . '...' : $tmpBody) . "</div>"; $class_html5 = ""; if ($this -> type == Ynvideo_Plugin_Factory::getVideoURLType() || $this -> type == Ynvideo_Plugin_Factory::getUploadedType()) { $class_html5 = 'html5_player'; } $totalLike = Engine_Api::_() -> getDbtable('likes', 'yncomment') -> likes($this) -> getLikeCount(); $totalDislike = Engine_Api::_() -> getDbtable('dislikes', 'yncomment') -> getDislikeCount($this); $videoEmbedded = '<div class="video_info">' .$title . $description . '</div>'.$thumb . '<div id="video_object_' . $this -> video_id . '" class="video_object ' . $class_html5 . '">' . $videoEmbedded . '</div>'; $view = Zend_Registry::get('Zend_View'); $videoEmbedded .= '<div class="tfvideo_statistics"> <span>'. $view->translate(array('%s like', '%s likes', $totalLike), $totalLike). '</span> <span>'. $view->translate(array('%s dislike', '%s dislikes', $totalDislike), $totalDislike). '</span> <span>'. $view->translate(array('%s comment', '%s comments', $this -> comment_count), $this -> comment_count).'</span> </div>'; } return $videoEmbedded; }
protected function _insertSearch($resourceType, $resourceId, $searchData = array()) { $defaultData = array('type' => $resourceType, 'id' => $resourceId, 'title' => '', 'description' => '', 'keywords' => '', 'hidden' => ''); $searchData = array_merge($defaultData, array_filter($searchData)); if ($searchData['description']) { $description = strip_tags($searchData['description']); $searchData['description'] = Engine_String::strlen($description) > 255 ? Engine_String::substr($description, 0, 252) . '...' : $description; } try { $this->getToDb()->insert('engine4_core_search', $searchData); } catch (Exception $e) { // ignore exception } }
public function createAction() { $this->view->options = array(); $this->view->form = $form = new Ynfeedback_Form_Admin_Polls_Create(); $viewer = Engine_Api::_()->user()->getViewer(); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Check options $options = (array) $this->_getParam('optionsArray'); $options = array_filter(array_map('trim', $options)); $options = array_slice($options, 0, $max_options); $this->view->options = $options; if (empty($options) || !is_array($options) || count($options) < 2) { return $form->addError('You must provide at least two possible answers.'); } foreach ($options as $index => $option) { if (strlen($option) > 80) { $options[$index] = Engine_String::substr($option, 0, 80); } } // Process $pollTable = Engine_Api::_()->getItemTable('ynfeedback_poll'); $pollOptionsTable = Engine_Api::_()->getDbtable('options', 'ynfeedback'); $db = $pollTable->getAdapter(); $db->beginTransaction(); try { $values = $form->getValues(); $values['user_id'] = $viewer->getIdentity(); // Create poll $poll = $pollTable->createRow(); $poll->setFromArray($values); $poll->save(); // Create options $censor = new Engine_Filter_Censor(); $html = new Engine_Filter_Html(array('AllowedTags' => array('a'))); foreach ($options as $option) { $option = $censor->filter($html->filter($option)); $pollOptionsTable->insert(array('poll_id' => $poll->getIdentity(), 'poll_option' => $option)); } $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array(''))); }
public function createAction() { if (!$this->_helper->requireUser()->isValid()) { return; } if (!$this->_helper->requireAuth()->setAuthParams('poll', null, 'create')->isValid()) { return; } // Get navigation $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('poll_main'); $this->view->options = array(); $this->view->maxOptions = $max_options = Engine_Api::_()->getApi('settings', 'core')->getSetting('poll.maxoptions', 15); $this->view->form = $form = new Poll_Form_Create(); $viewer = Engine_Api::_()->user()->getViewer(); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Check options $options = (array) $this->_getParam('optionsArray'); $options = array_filter(array_map('trim', $options)); $options = array_slice($options, 0, $max_options); $this->view->options = $options; if (empty($options) || !is_array($options) || count($options) < 2) { return $form->addError('You must provide at least two possible answers.'); } foreach ($options as $index => $option) { if (strlen($option) > 80) { $options[$index] = Engine_String::substr($option, 0, 80); } } // Process $pollTable = Engine_Api::_()->getItemTable('poll'); $pollOptionsTable = Engine_Api::_()->poll()->api()->getDbtable('options', 'poll'); $db = $pollTable->getAdapter(); $db->beginTransaction(); try { $values = $form->getValues(); $values['user_id'] = $viewer->getIdentity(); // Create poll $poll = $pollTable->createRow(); $poll->setFromArray($values); $poll->save(); // Create options $censor = new Engine_Filter_Censor(); foreach ($options as $option) { $pollOptionsTable->insert(array('poll_id' => $poll->getIdentity(), 'poll_option' => $censor->filter($option))); } // Privacy $auth = Engine_Api::_()->authorization()->context; $roles = array('owner', 'owner_member', 'owner_member_member', 'owner_network', 'registered', 'everyone'); if (empty($values['auth_view'])) { $values['auth_view'] = array('everyone'); } if (empty($values['auth_comment'])) { $values['auth_comment'] = array('everyone'); } $viewMax = array_search($values['auth_view'], $roles); $commentMax = array_search($values['auth_comment'], $roles); foreach ($roles as $i => $role) { $auth->setAllowed($poll, $role, 'view', $i <= $viewMax); $auth->setAllowed($poll, $role, 'comment', $i <= $commentMax); } $auth->setAllowed($poll, 'registered', 'vote', true); $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } // Process activity $db = Engine_Api::_()->getDbTable('polls', 'poll')->getAdapter(); $db->beginTransaction(); try { $action = Engine_Api::_()->getDbtable('actions', 'activity')->addActivity(Engine_Api::_()->user()->getViewer(), $poll, 'poll_new'); if ($action) { Engine_Api::_()->getDbtable('actions', 'activity')->attachActivity($action, $poll); } $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } // Redirect return $this->_helper->redirector->gotoUrl($poll->getHref(), array('prependBase' => false)); }
public function createAction() { if (!$this->_helper->requireUser()->isValid()) { return; } if (!$this->_helper->requireSubject('group')->isValid()) { return; } $this->view->group = $group = Engine_Api::_()->core()->getSubject('group'); $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer(); // if ($group -> is_subgroup) { // $parent_group = $group -> getParentGroup(); // if (!$parent_group -> authorization() -> isAllowed(null, 'poll')) { // return $this -> _helper -> requireAuth -> forwards(); // } else if (!$group -> authorization() -> isAllowed(null, 'poll')) { // return $this -> _helper -> requireAuth -> forwards(); // } // } else if (!$group->authorization()->isAllowed(null, 'poll')) { return $this->_helper->requireAuth->forwards(); } // Make form $this->view->form = $form = new Advgroup_Form_Poll_Create(); $this->view->options = array(); $this->view->maxOptions = $max_options = Engine_Api::_()->getApi('settings', 'core')->getSetting('advgroup.pollmaxoptions', 15); $this->view->form = $form = new Advgroup_Form_Poll_Create(); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Check options $options = (array) $this->_getParam('optionsArray'); $options = array_filter(array_map('trim', $options)); $options = array_slice($options, 0, $max_options); $this->view->options = $options; if (empty($options) || !is_array($options) || count($options) < 2) { return $form->addError('You must provide at least two possible answers.'); } foreach ($options as $index => $option) { if (strlen($option) > 80) { $options[$index] = Engine_String::substr($option, 0, 80); } } // Process $pollTable = Engine_Api::_()->getItemTable('advgroup_poll'); $pollOptionsTable = Engine_Api::_()->getDbtable('pollOptions', 'advgroup'); $db = $pollTable->getAdapter(); $db->beginTransaction(); try { $values = $form->getValues(); $values['user_id'] = $viewer->getIdentity(); $values['group_id'] = $group->group_id; // Create poll $poll = $pollTable->createRow(); $poll->setFromArray($values); $poll->save(); // Create options $censor = new Engine_Filter_Censor(); $html = new Engine_Filter_HtmlSpecialChars(); foreach ($options as $option) { $option = $censor->filter($html->filter($option)); $pollOptionsTable->insert(array('poll_id' => $poll->getIdentity(), 'poll_option' => $option)); } $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } // Process privacy $auth = Engine_Api::_()->authorization()->context; $roles = array('officer', 'member', 'registered', 'everyone'); if (empty($values['auth_comment'])) { $values['auth_comment'] = 'registered'; } $commentMax = array_search($values['auth_comment'], $roles); $officerList = $group->getOfficerList(); foreach ($roles as $i => $role) { if ($role === 'officer') { $role = $officerList; } $auth->setAllowed($poll, $role, 'comment', $i <= $commentMax); } // Process activity $db = Engine_Api::_()->getDbTable('polls', 'advgroup')->getAdapter(); $db->beginTransaction(); try { $action = Engine_Api::_()->getDbtable('actions', 'activity')->addActivity(Engine_Api::_()->user()->getViewer(), $group, 'advgroup_poll_new', $poll); if ($action) { Engine_Api::_()->getDbtable('actions', 'activity')->attachActivity($action, $poll); } $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } $this->_helper->redirector->gotoRoute(array('controller' => 'poll', 'action' => 'manage', 'subject' => $group->getGuid()), 'group_extended', true); }
/** * Gets a url slug for this item, based on it's title * * @return string The slug */ public function getSlug($str = null) { if (null === $str) { $str = $this->getTitle(); } if (strlen($str) > 64) { $str = Engine_String::substr($str, 0, 64) . '...'; } $search = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ẩ', 'Ầ', 'Ẫ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'ạ', 'à', 'á', 'ả', 'â', 'ậ', 'ã', 'ä', 'å', 'ầ', 'ẫ', 'æ', 'ắ', 'ằ', 'ẩ', 'ấ', 'ặ', 'ç', 'ẹ', 'è', 'é', 'ê', 'ế', 'ề', 'ệ', 'ë', 'ẻ', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ổ', 'ô', 'õ', 'ö', 'ø', 'ộ', 'ồ', 'ờ', 'ơ', 'ở', 'ợ', 'ỏ', 'ỡ', 'ù', 'ú', 'ứ', 'û', 'ü', 'ừ', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'ẽ', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'ể', 'ễ', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'ị', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'ố', 'ỗ', 'ớ', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'ủ', 'Ų', 'ų', 'ử', 'ụ', 'ự', 'ừ', 'ứ', 'ữ', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'ỷ', 'ỳ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'ọ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'ứ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ'); $replace = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'e', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'o', 'o', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'u', 'U', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'W', 'w', 'Y', 'y', 'y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o'); $str = str_replace($search, $replace, $str); $str = preg_replace('/([a-z])([A-Z])/', '$1 $2', $str); $str = strtolower($str); $str = preg_replace('/[^a-z0-9-]+/i', '-', $str); $str = preg_replace('/-+/', '-', $str); $str = trim($str, '-'); if (!$str) { $str = '-'; } return $str; }
public function getDescription() { $content = strip_tags($this->description); return Engine_String::substr($content, 0, 255); }
public function getDescription() { // @todo decide how we want to handle multibyte string functions $tmpBody = strip_tags($this->description); return Engine_String::strlen($tmpBody) > 255 ? Engine_String::substr($tmpBody, 0, 255) . '...' : $tmpBody; }
/** * @url : http://localhost/pcus907/ynmember/member/share/type/user/id/1/format/smoothbox * Sharing member * @throws Exception */ public function shareAction() { if (!$this->_helper->requireUser()->isValid()) { return; } $type = $this->_getParam('type'); $id = $this->_getParam('id'); $viewer = Engine_Api::_()->user()->getViewer(); $this->view->attachment = $attachment = Engine_Api::_()->getItem($type, $id); $this->view->form = $form = new Activity_Form_Share(); if (!$attachment) { // tell smoothbox to close $this->view->status = true; $this->view->message = Zend_Registry::get('Zend_Translate')->_('You cannot share this item because it has been removed.'); $this->view->smoothboxClose = true; return $this->render('deletedItem'); } // hide facebook and twitter option if not logged in $facebookTable = Engine_Api::_()->getDbtable('facebook', 'user'); if (!$facebookTable->isConnected()) { $form->removeElement('post_to_facebook'); } $twitterTable = Engine_Api::_()->getDbtable('twitter', 'user'); if (!$twitterTable->isConnected()) { $form->removeElement('post_to_twitter'); } if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $db = Engine_Api::_()->getDbtable('actions', 'activity')->getAdapter(); $db->beginTransaction(); try { // Get body $body = $form->getValue('body'); // Set Params for Attachment $params = array(); // Add activity $api = Engine_Api::_()->getDbtable('actions', 'activity'); //$action = $api->addActivity($viewer, $viewer, 'post_self', $body); $action = $api->addActivity($viewer, $attachment->getOwner(), 'ynmember_share', $body, $params); if ($action) { $api->attachActivity($action, $attachment); } $db->commit(); // Notifications $notifyApi = Engine_Api::_()->getDbtable('notifications', 'activity'); // Add notification for owner of activity (if user and not viewer) if ($action->subject_type == 'user' && $attachment->getOwner()->getIdentity() != $viewer->getIdentity()) { $notifyApi->addNotification($attachment->getOwner(), $viewer, $action, 'ynmember_shared', array('label' => $this->view->translate('you'))); } // Preprocess attachment parameters $publishMessage = html_entity_decode($form->getValue('body')); $publishUrl = null; $publishName = null; $publishDesc = null; $publishPicUrl = null; // Add attachment if ($attachment) { $publishUrl = $attachment->getHref(); $publishName = $attachment->getTitle(); $publishDesc = $attachment->getDescription(); if (empty($publishName)) { $publishName = ucwords($attachment->getShortType()); } if ($tmpPicUrl = $attachment->getPhotoUrl()) { $publishPicUrl = $tmpPicUrl; } // prevents OAuthException: (#100) FBCDN image is not allowed in stream if ($publishPicUrl && preg_match('/fbcdn.net$/i', parse_url($publishPicUrl, PHP_URL_HOST))) { $publishPicUrl = null; } } else { $publishUrl = $action->getHref(); } // Check to ensure proto/host if ($publishUrl && false === stripos($publishUrl, 'http://') && false === stripos($publishUrl, 'https://')) { $publishUrl = 'http://' . $_SERVER['HTTP_HOST'] . $publishUrl; } if ($publishPicUrl && false === stripos($publishPicUrl, 'http://') && false === stripos($publishPicUrl, 'https://')) { $publishPicUrl = 'http://' . $_SERVER['HTTP_HOST'] . $publishPicUrl; } // Add site title if ($publishName) { $publishName = Engine_Api::_()->getApi('settings', 'core')->core_general_site_title . ": " . $publishName; } else { $publishName = Engine_Api::_()->getApi('settings', 'core')->core_general_site_title; } // Publish to facebook, if checked & enabled if ($this->_getParam('post_to_facebook', false) && 'publish' == Engine_Api::_()->getApi('settings', 'core')->core_facebook_enable) { try { $facebookTable = Engine_Api::_()->getDbtable('facebook', 'user'); $facebookApi = $facebook = $facebookTable->getApi(); $fb_uid = $facebookTable->find($viewer->getIdentity())->current(); if ($fb_uid && $fb_uid->facebook_uid && $facebookApi && $facebookApi->getUser() && $facebookApi->getUser() == $fb_uid->facebook_uid) { $fb_data = array('message' => $publishMessage); if ($publishUrl) { $fb_data['link'] = $publishUrl; } if ($publishName) { $fb_data['name'] = $publishName; } if ($publishDesc) { $fb_data['description'] = $publishDesc; } if ($publishPicUrl) { $fb_data['picture'] = $publishPicUrl; } $res = $facebookApi->api('/me/feed', 'POST', $fb_data); } } catch (Exception $e) { // Silence } } // end Facebook // Publish to twitter, if checked & enabled if ($this->_getParam('post_to_twitter', false) && 'publish' == Engine_Api::_()->getApi('settings', 'core')->core_twitter_enable) { try { $twitterTable = Engine_Api::_()->getDbtable('twitter', 'user'); if ($twitterTable->isConnected()) { // Get attachment info $title = $attachment->getTitle(); $url = $attachment->getHref(); $picUrl = $attachment->getPhotoUrl(); // Check stuff if ($url && false === stripos($url, 'http://')) { $url = 'http://' . $_SERVER['HTTP_HOST'] . $url; } if ($picUrl && false === stripos($picUrl, 'http://')) { $picUrl = 'http://' . $_SERVER['HTTP_HOST'] . $picUrl; } // Try to keep full message // @todo url shortener? $message = html_entity_decode($form->getValue('body')); if (strlen($message) + strlen($title) + strlen($url) + strlen($picUrl) + 9 <= 140) { if ($title) { $message .= ' - ' . $title; } if ($url) { $message .= ' - ' . $url; } if ($picUrl) { $message .= ' - ' . $picUrl; } } else { if (strlen($message) + strlen($title) + strlen($url) + 6 <= 140) { if ($title) { $message .= ' - ' . $title; } if ($url) { $message .= ' - ' . $url; } } else { if (strlen($title) > 24) { $title = Engine_String::substr($title, 0, 21) . '...'; } // Sigh truncate I guess if (strlen($message) + strlen($title) + strlen($url) + 9 > 140) { $message = Engine_String::substr($message, 0, 140 - (strlen($title) + strlen($url) + 9)) - 3 . '...'; } if ($title) { $message .= ' - ' . $title; } if ($url) { $message .= ' - ' . $url; } } } $twitter = $twitterTable->getApi(); $twitter->statuses->update($message); } } catch (Exception $e) { // Silence } } // Publish to janrain if ('publish' == Engine_Api::_()->getApi('settings', 'core')->core_janrain_enable) { try { $session = new Zend_Session_Namespace('JanrainActivity'); $session->unsetAll(); $session->message = $publishMessage; $session->url = $publishUrl ? $publishUrl : 'http://' . $_SERVER['HTTP_HOST'] . _ENGINE_R_BASE; $session->name = $publishName; $session->desc = $publishDesc; $session->picture = $publishPicUrl; } catch (Exception $e) { // Silence } } } catch (Exception $e) { $db->rollBack(); throw $e; // This should be caught by error handler } // Disable layout and viewrenderer //$this -> _helper -> layout -> disableLayout(); return $this->_forward('success', 'utility', 'core', array('smoothboxClose' => true, 'parentRefresh' => false, 'layout' => 'default-simple', 'messages' => array(Zend_Registry::get('Zend_Translate')->_('Shared This Member Successfully!')))); exit; }
public function viewMore($string, $moreLength = null, $maxLength = null, $lessLength = null, $nl2br = true) { if (!is_numeric($moreLength) || $moreLength <= 0) { $moreLength = $this->_moreLength; } if (!is_numeric($maxLength) || $maxLength <= 0) { $maxLength = $this->_maxLength; } if (!is_numeric($lessLength) || $lessLength <= 0) { $lessLength = $this->_lessLength; } // If using line breaks, ensure that there are not too many line breaks if ($nl2br) { $string = trim(preg_replace('/(\\r\\n|\\n\\r|\\r|\\n)/', "\n", $string)); if (($c = substr_count($string, "\n")) > $this->_maxLineBreaks) { $pos = 0; for ($i = 0; $i < $this->_maxLineBreaks; $i++) { $pos = strpos($string, "\n", $pos + 1); } if ($pos <= 0 || !is_int($pos)) { $pos = null; } if ($pos && $pos < $moreLength) { $moreLength = $pos; } } } // If length is less than max len, just return $strLen = Engine_String::strlen($string); if ($strLen <= $moreLength + $this->_fudgesicles) { if ($nl2br) { return nl2br($string); } else { return $string; } } // Otherwise truncate if ($strLen >= $maxLength) { $strLen = $maxLength; $string = Engine_String::substr($string, 0, $maxLength) . $this->view->translate('... '); } $shortText = Engine_String::substr($string, 0, $moreLength); $fullText = $string; // Do nl2br if ($nl2br) { $shortText = nl2br($shortText); $fullText = nl2br($fullText); } $onclick = <<<EOF var me = \$(this).getParent(), other = \$(this).getParent().getNext(), fn = function() { me.style.display = 'none'; other.style.display = ''; }; fn(); setTimeout(fn, 0); EOF; $content = '<' . $this->_tag . ' class="view_more"' . '>' . $shortText . $this->view->translate('... ') . '<a class="view_more_link" href="javascript:void(0);" onclick="' . htmlspecialchars($onclick) . '">' . $this->view->translate('more') . '</a>' . '</' . $this->_tag . '>' . '<' . $this->_tag . ' class="view_more"' . ' style="display:none;"' . '>' . $fullText . ' '; if ($strLen >= $lessLength) { $onclick = <<<EOF var me = \$(this).getParent(), other = \$(this).getParent().getPrevious(), fn = function() { me.style.display = 'none'; other.style.display = ''; }; fn(); setTimeout(fn, 0); EOF; $content .= '<a class="view_less_link" href="javascript:void(0);" onclick="' . htmlspecialchars($onclick) . '">' . $this->view->translate('less') . '</a>'; } $content .= '</' . $this->_tag . '>'; return $content; }
public function getDescription() { // Remove bbcode $desc = strip_tags($this->body); return Engine_String::substr($desc, 0, 255); }