本文整理匯總了PHP中Languages::getAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP Languages::getAll方法的具體用法?PHP Languages::getAll怎麽用?PHP Languages::getAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Languages
的用法示例。
在下文中一共展示了Languages::getAll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: submitAction
/**
* Submit Feed to website
*
* @return
*/
public function submitAction()
{
$this->view->keywords = implode('', array('ifphp', 'news aggragator', 'submit rss feed'));
$form = $this->getSubmitForm();
//setup the available categories
$categories = new Categories();
$this->view->categories = $categories->getAll();
foreach ($this->view->categories as $category) {
$form->category->addMultiOptions(array($category->id => $category->title));
}
//setup the available languages
$languages = new Languages();
$this->view->languages = $languages->getAll();
foreach ($this->view->languages as $language) {
$form->language->addMultiOptions(array($language->id => $language->title));
}
//if it's a post submit let's save the information
if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
//TODO this shoudl be wrapped in a transaction
//create user
$users = new Users();
//check for existance of a user
$user = $users->getByEmail($form->email->getValue());
if (!$user) {
$user = $users->createRow();
$user->email = $form->email->getValue();
$user->fullName = $form->fullname->getValue();
$user->username = 'temporaryusername';
//TODO put real username here eventually
$user->password = '';
$user->roleId = Role::SUBMITTER;
$user->statusId = Status::ACTIVE;
$user->save();
}
try {
$feedSource = Zend_Feed_Reader::import($form->url->getValue());
//convert/parse feed to strongly typed objects
$defaultFilterChain = new Zend_Filter();
$defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
$defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
$defaultFilterChain->addFilter(new Zend_Filter_StripTags());
$feeds = new Feeds();
$feed = $feeds->createRow();
$feed->token = md5(uniqid($user->id));
$feed->url = $defaultFilterChain->filter($form->url->getValue());
$feed->title = $defaultFilterChain->filter($feedSource->getTitle());
$inflector = new Zend_Filter_Inflector(':title');
$inflector->setRules(array(':title' => array('Word_SeparatorToDash', 'StringToLower', 'HtmlEntities')));
$feed->slug = $inflector->filter(array('title' => $feed->title));
$feed->description = $defaultFilterChain->filter($feedSource->getDescription());
$feed->categoryId = $form->category->getValue();
$feed->languageId = $form->language->getValue();
$feed->siteUrl = $form->siteUrl->getValue();
$feed->statusId = Status::PENDING;
$feed->userId = $user->id;
$feed->refreshRate = 120;
//TODO this is sometimes stored in the feed
$feed->save();
//parse feed
$posts = new Posts();
foreach ($feedSource as $feedEntry) {
$post = $posts->createRow();
$post->title = $defaultFilterChain->filter($feedEntry->getTitle());
$post->description = $defaultFilterChain->filter($feedEntry->getDescription());
$post->link = $defaultFilterChain->filter($feedEntry->getPermaLink());
$post->feedId = $feed->id;
$date = new Zend_Date($feedEntry->getDateModified());
$post->publishDate = $date->toValue();
$post->save();
}
// $this->_flashMessenger->addMessage('Your feed has been added to the site. Your ping back url is http://ifphp.com/feed/ping-back/'.$feed->token);
$this->sendActivationEmail($feed, $user);
$this->_forward('submit-thank-you');
} catch (Zend_Feed_Exception $error) {
$form->url->markAsError();
Zend_Registry::getInstance()->logger->err($error);
return;
}
}
$this->view->form = $form;
}
示例2: listAction
public function listAction()
{
//setup the available languages
$languages = new Languages();
$this->view->languages = $languages->getAll();
}