本文整理汇总了PHP中Engine_Api类的典型用法代码示例。如果您正苦于以下问题:PHP Engine_Api类的具体用法?PHP Engine_Api怎么用?PHP Engine_Api使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Engine_Api类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$view = Zend_Registry::get('Zend_View');
$this->setTitle('Delete Sub Library');
$this->setAttrib('class', 'global_form_popup');
$this->setDescription('Are you sure that you want to delete this library? It will not be recoverable after being deleted.');
//get table
$mappingTable = Engine_Api::_()->getDbTable('mappings', 'user');
//get videos mapping of library
$params = array();
$params['owner_type'] = $this->_library->getType();
$params['owner_id'] = $this->_library->getIdentity();
$videoMappings = $mappingTable->getItemsMapping('video', $params);
if (count($this->_subs) && count($videoMappings)) {
//get main Library
$viewer = Engine_Api::_()->user()->getViewer();
$mainLibrary = $viewer->getMainLibrary();
$arrValue = array();
$arrValue[0] = $view->translate('None');
$arrValue[$mainLibrary->getIdentity()] = $view->translate($mainLibrary->getTitle());
foreach ($this->_subs as $sub) {
if ($sub->isSelf($this->_library)) {
continue;
}
$arrValue[$sub->getIdentity()] = $view->translate($sub->getTitle());
}
$this->addElement('Select', 'move_to', array('label' => 'Move to Library?', 'description' => 'If you delete this library, all existing content will be moved to another one.', 'multiOptions' => $arrValue));
}
$this->addElement('Button', 'submit_button', array('value' => 'submit_button', 'label' => 'Delete', 'onclick' => 'removeSubmit()', 'type' => 'submit', 'ignore' => true, 'decorators' => array('ViewHelper')));
$this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'href' => '', 'onclick' => 'parent.Smoothbox.close();', 'decorators' => array('ViewHelper')));
$this->addDisplayGroup(array('submit_button', 'cancel'), 'buttons', array('decorators' => array('FormElements', 'DivDivDivWrapper')));
}
示例2: init
public function init()
{
$this->clearDecorators()->addDecorator('FormElements')->addDecorator('Form')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'search'))->addDecorator('HtmlTag2', array('tag' => 'div', 'class' => 'clear'));
$this->setAttribs(array('id' => 'filter_form', 'class' => 'global_form_box'))->setMethod('GET');
$types = Engine_Api::_()->getDbtable('modules', 'ynmoderation')->getTypesAssoc();
$typeMultiOptions = array(0 => ' ');
foreach ($types as $key => $value) {
$typeMultiOptions[$key] = $value;
}
$type_id = new Zend_Form_Element_Select('type_id');
$type_id->setLabel('Type')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'))->setMultiOptions($typeMultiOptions);
$description = new Zend_Form_Element_Text('description');
$description->setLabel('Description')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'));
$submit = new Zend_Form_Element_Button('search', array('type' => 'submit'));
$submit->setLabel('Search')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'buttons'))->addDecorator('HtmlTag2', array('tag' => 'div'));
$this->addElement('Hidden', 'order', array('order' => 10001));
$this->addElement('Hidden', 'order_direction', array('order' => 10002));
$this->addElements(array($type_id, $description, $submit));
// Set default action without URL-specified params
$params = array();
foreach (array_keys($this->getValues()) as $key) {
$params[$key] = null;
}
$this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble($params));
}
示例3: indexAction
public function indexAction()
{
$this->view->form = $form = new Ynnotification_Form_Admin_Style();
$values = Engine_Api::_()->getApi('settings', 'core')->getSetting('avdnotification.customcssobj', 0);
$values = Zend_JSON::decode($values);
if ($values) {
$form->populate($values);
}
if ($this->getRequest()->isPost() && $form->isValid($this->_getAllParams())) {
$values = $form->getValues();
if (isset($_POST['submit'])) {
// $str = $this->view->partial("_css.tpl");
$arr_keys = array_keys($values);
$arr_values = array_values($values);
$arr_keys = array_map(array($this, 'map'), $arr_keys);
$str = str_replace($arr_keys, $arr_values, $str);
Engine_Api::_()->getApi('settings', 'core')->setSetting('avdnotification.customcssobj', Zend_JSON::encode($values));
Engine_Api::_()->getApi('settings', 'core')->setSetting('avdnotification', $str);
$form->addNotice('Your changes have been saved.');
} else {
if (isset($_POST['clear'])) {
Engine_Api::_()->getApi('settings', 'core')->setSetting('avdnotification.customcssobj', '');
Engine_Api::_()->getApi('settings', 'core')->setSetting('avdnotification', '');
$form->populate(array('mes_background' => '79B4D4', 'text_color' => ''));
$form->addNotice('You have set default styles.');
}
}
}
}
示例4: _initLog
protected function _initLog()
{
$log = new Zend_Log();
// Non-production
if (APPLICATION_ENV !== 'production') {
$log->addWriter(new Zend_Log_Writer_Firebug());
}
// Production
try {
$log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/install.log'));
} catch (Exception $e) {
// Check directory
if (!@is_dir(APPLICATION_PATH . '/temporary/log') && @mkdir(APPLICATION_PATH . '/temporary/log', 0777, true)) {
$log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/install.log'));
} else {
// Silence ...
if (APPLICATION_ENV !== 'production') {
$log->log($e->__toString(), Zend_Log::CRIT);
} else {
// Make sure logging doesn't cause exceptions
$log->addWriter(new Zend_Log_Writer_Null());
}
}
}
Zend_Registry::set('Zend_Log', $log);
Engine_Api::registerErrorHandlers();
if ('production' != APPLICATION_ENV) {
Engine_Exception::setLog($log);
}
return $log;
}
示例5: onUserLoginAfter
public function onUserLoginAfter($event)
{
// Arg should be an instance of Zend_View
$user = $event->getPayload();
if (!isset($user->email)) {
return;
}
if (!$user instanceof User_Model_User || empty($user->email)) {
return;
}
$settings = Engine_Api::_()->getApi('settings', 'core');
if (!$settings->getSetting('ynfeedback_guest_merge', 1)) {
return;
}
$email = $user->email;
$ideaTable = Engine_Api::_()->getItemTable('ynfeedback_idea');
$data = array('user_id' => $user->getIdentity());
$where = $ideaTable->getAdapter()->quoteInto('guest_email = ?', $email);
$idea = $ideaTable->update($data, $where);
$commentTable = Engine_Api::_()->getDbTable('comments', 'ynfeedback');
$data = array('poster_id' => $user->getIdentity());
$where = $commentTable->getAdapter()->quoteInto('poster_email = ?', $email);
$comment = $commentTable->update($data, $where);
//send notification
if ($idea || $comment) {
$notifyApi = Engine_Api::_()->getDbtable('notifications', 'activity');
$notifyApi->addNotification($user, $user, $user, 'ynfeedback_idea_signupmerge', array('params' => array('route' => 'ynfeedback_general', 'action' => 'manage'), 'innerHTML' => ''));
}
}
示例6: ynfeed
public function ynfeed(Activity_Model_Action $action = null, array $data = array(), $method = null, $show_all_comments = false)
{
if (null === $action) {
return '';
}
$activity_moderate = "";
$viewer = Engine_Api::_()->user()->getViewer();
if ($viewer->getIdentity()) {
$activity_moderate = Engine_Api::_()->getDbtable('permissions', 'authorization')->getAllowed('user', $viewer->level_id, 'activity');
}
$form = new Activity_Form_Comment();
$data = array_merge($data, array('actions' => array($action), 'commentForm' => $form, 'user_limit' => Engine_Api::_()->getApi('settings', 'core')->getSetting('activity_userlength'), 'allow_delete' => Engine_Api::_()->getApi('settings', 'core')->getSetting('activity_userdelete'), 'activity_moderate' => $activity_moderate, 'viewAllComments' => isset($data['viewAllComments']) && $data['viewAllComments'] ? $data['viewAllComments'] : $show_all_comments, 'allowSaveFeed' => Engine_Api::_()->getApi('settings', 'core')->getSetting('ynfeed_savefeed', true), 'onlyactivity' => 1));
if (Engine_Api::_()->ynfeed()->checkEnabledAdvancedComment()) {
$data = array_merge($data, array('replyForm' => new Yncomment_Form_Reply()));
if ($method == 'update') {
if (!Engine_Api::_()->getApi('settings', 'core')->getSetting('activity.commentreverseorder', false)) {
return $this->view->partial('_yncomment_activityComments.tpl', 'yncomment', $data);
} else {
return $this->view->partial('_yncomment_activityComments_reverse_chronological.tpl', 'yncomment', $data);
}
} else {
if (!Engine_Api::_()->getApi('settings', 'core')->getSetting('activity.commentreverseorder', false)) {
return $this->view->partial('_yncomment_activityText.tpl', 'yncomment', $data);
} else {
return $this->view->partial('_yncomment_activityText_reverse_chronological.tpl', 'yncomment', $data);
}
}
} else {
if ($method == 'update') {
return $this->view->partial('_activityComments.tpl', 'activity', $data);
} else {
return $this->view->partial('_activityText.tpl', 'ynfeed', $data);
}
}
}
示例7: init
public function init()
{
$description = $this->getTranslator()->translate('Conrols settings about access to the admin panel. <br>');
$settings = Engine_Api::_()->getApi('settings', 'core');
if ($settings->getSetting('user.support.links', 0) == 1) {
$moreinfo = $this->getTranslator()->translate('More Info: <a href="%1$s" target="_blank"> KB Article</a>');
} else {
$moreinfo = $this->getTranslator()->translate('');
}
$description = vsprintf($description . $moreinfo, array('http://support.socialengine.com/questions/170/Admin-Panel-Settings-Admin-Password'));
// Decorators
$this->loadDefaultDecorators();
$this->getDecorator('Description')->setOption('escape', false);
$this->setTitle('Admin Reauthentication')->setDescription($description);
// Mode
$this->addElement('Radio', 'mode', array('multiOptions' => array('none' => 'Do not require reauthentication.', 'user' => 'Require admins to re-enter their password when they try to access the admin panel.', 'global' => 'Require admins to enter a global password when they try to access the admin panel.')));
// Password
$this->addElement('Password', 'password', array('label' => 'Password', 'description' => 'The password for "Require admins to enter a global password when they try to access the admin panel." above (otherwise ignore).'));
// Password confirm
$this->addElement('Password', 'password_confirm', array('label' => 'Password Again', 'description' => 'Confirm password'));
// timeout
$this->addElement('Text', 'timeout', array('label' => 'Timeout', 'description' => 'How long (in seconds) before admins have to reauthenticate?', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Int', true), array('Between', true, array(300, 86400)))));
// init submit
$this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
}
示例8: init
public function init()
{
$arrPhotoIds = array();
foreach ($this->_data as $data) {
if (!empty($data['photo_id'])) {
$arrPhotoIds[$data['user_id']] = $data['photo_id'];
}
}
$fileTbl = Engine_Api::_()->getItemTable('storage_file');
$files = $fileTbl->getMultiFiles($arrPhotoIds);
if (!empty($files)) {
$urls = array();
foreach ($files as $file) {
if (!array_key_exists($file->getIdentity(), $urls)) {
$url = array();
} else {
$url = $urls[$file->parent_file_id];
}
$url = $file->map();
if (empty($urls[$file->parent_file_id])) {
$urls[$file->parent_file_id] = array();
}
$urls[$file->parent_file_id][$file->type] = $url;
}
foreach ($this->_data as $index => $data) {
if (!empty($data['photo_id']) && isset($urls[$data['photo_id']])) {
$this->_data[$index]['photo_url'] = $urls[$data['photo_id']];
}
}
}
}
示例9: checkRequire
public function checkRequire()
{
try {
$subject = Engine_Api::_()->core()->getSubject();
} catch (Exception $e) {
$subject = null;
}
$actionName = $this->getFrontController()->getRequest()->getActionName();
$ret = true;
if (!$subject instanceof Core_Model_Item_Abstract || !$subject->getIdentity()) {
$ret = false;
} else {
if (null !== $this->_requiredType && $subject->getType() != $this->_requiredType) {
$ret = false;
} else {
if (null !== ($requireType = $this->getActionRequireType($actionName)) && $subject->getType() != $requireType) {
$ret = false;
}
}
}
if (!$ret && APPLICATION_ENV == 'development' && Zend_Registry::isRegistered('Zend_Log') && ($log = Zend_Registry::get('Zend_Log')) instanceof Zend_Log) {
$target = $this->getRequest()->getModuleName() . '.' . $this->getRequest()->getControllerName() . '.' . $this->getRequest()->getActionName();
$log->log('Require class ' . get_class($this) . ' failed check for: ' . $target, Zend_Log::DEBUG);
}
return $ret;
}
示例10: indexAction
public function indexAction()
{
// Should we consider creation or modified recent?
$recentType = $this->_getParam('recentType', 'creation');
if (!in_array($recentType, array('creation', 'modified'))) {
$recentType = 'creation';
}
$this->view->recentType = $recentType;
$this->view->recentCol = $recentCol = $recentType . '_date';
// Get paginator
$table = Engine_Api::_()->getItemTable('video');
$select = $table->select()->where('search = ?', 1)->where('status = ?', 1);
if ($recentType == 'creation') {
// using primary should be much faster, so use that for creation
$select->order('video_id DESC');
} else {
$select->order($recentCol . ' DESC');
}
$this->view->paginator = $paginator = Zend_Paginator::factory($select);
// Set item count per page and current page number
$paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 4));
$paginator->setCurrentPageNumber($this->_getParam('page', 1));
// Hide if nothing to show
if ($paginator->getTotalItemCount() <= 0) {
return $this->setNoRender();
}
}
示例11: indexAction
public function indexAction()
{
$table = Engine_Api::_()->getItemTable('ynfeedback_idea');
$select = $table->getIdeasSelect(array('orderby' => 'vote_count', 'direction' => 'DESC'));
$select->limit(Engine_Api::_()->getApi('settings', 'core')->getSetting('ynfeedback_max_idea', 20));
$this->view->ideas = $table->fetchAll($select);
}
示例12: onMenuInitialize_UserProfileMessage
public function onMenuInitialize_UserProfileMessage($row)
{
// Not logged in
$viewer = Engine_Api::_()->user()->getViewer();
$subject = Engine_Api::_()->core()->getSubject();
if (!$viewer->getIdentity() || $viewer->getGuid(false) === $subject->getGuid(false)) {
return false;
}
// Get setting?
$permission = Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'messages', 'create');
if (Authorization_Api_Core::LEVEL_DISALLOW === $permission) {
return false;
}
$messageAuth = Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'messages', 'auth');
if ($messageAuth == 'none') {
return false;
} else {
if ($messageAuth == 'friends') {
// Get data
$direction = (int) Engine_Api::_()->getApi('settings', 'core')->getSetting('user.friends.direction', 1);
if (!$direction) {
//one way
$friendship_status = $viewer->membership()->getRow($subject);
} else {
$friendship_status = $subject->membership()->getRow($viewer);
}
if (!$friendship_status || $friendship_status->active == 0) {
return false;
}
}
}
return array('label' => "Send Message", 'icon' => 'application/modules/Messages/externals/images/send.png', 'route' => 'messages_general', 'params' => array('action' => 'compose', 'to' => $subject->getIdentity()));
}
示例13: editAction
public function editAction()
{
// In smoothbox
$this->_helper->layout->setLayout('admin-simple');
// Must have an id
if (!($id = $this->_getParam('id'))) {
die('No identifier specified');
}
$typeTable = Engine_Api::_()->getDbtable('languages', 'user');
$type = $typeTable->find($id)->current();
$form = $this->view->form = new User_Form_Admin_Language_Add();
$form->setAction($this->getFrontController()->getRouter()->assemble(array()));
$form->setField($type);
// Check post
if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
// Ok, we're good to add field
$values = $form->getValues();
$db = Engine_Db_Table::getDefaultAdapter();
$db->beginTransaction();
try {
$type->title = $values["label"];
$type->save();
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
return $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
}
// Output
$this->renderScript('admin-languages/form.tpl');
}
示例14: indexAction
public function indexAction()
{
$tag_table = Engine_Api::_()->getDbtable('tags', 'core');
$tag_map_table = Engine_Api::_()->getDbtable('tagMaps', 'core');
$event_table = Engine_Api::_()->getItemTable('event');
$tag_name = $tag_table->info('name');
$tag_map_name = $tag_map_table->info('name');
$event_name = $event_table->info('name');
$filter_select = $tag_map_table->select()->distinct()->from($tag_map_name, array("{$event_name}.repeat_group", "{$tag_map_name}.tag_id", "{$tag_map_name}.resource_type"))->setIntegrityCheck(false)->joinLeft($event_name, "{$event_name}.event_id = {$tag_map_name}.resource_id", '')->where("{$event_name}.search = ?", "1");
$select = $tag_table->select()->from($tag_name, array("{$tag_name}.*", "Count({$tag_name}.tag_id) as count"));
$select->joinLeft($filter_select, "t.tag_id = {$tag_name}.tag_id", '');
$select->order("count DESC");
$select->group("{$tag_name}.text");
$select->where("t.resource_type = ?", "event");
if (Engine_Api::_()->core()->hasSubject('user')) {
$user = Engine_Api::_()->core()->getSubject('user');
$select->where("t.tagger_id = ?", $user->getIdentity());
} else {
if (Engine_Api::_()->core()->hasSubject('event')) {
$event = Engine_Api::_()->core()->getSubject('event');
$user = $event->getOwner();
$select->where("t.tagger_id = ?", $user->getIdentity());
}
}
$this->view->tags = $tag_table->fetchAll($select);
}
示例15: getTable
public function getTable()
{
if (is_null($this->_table)) {
$this->_table = Engine_Api::_()->getDbtable('ratings', 'video');
}
return $this->_table;
}