當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XenForo_DataWriter::getModelFromCache方法代碼示例

本文整理匯總了PHP中XenForo_DataWriter::getModelFromCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP XenForo_DataWriter::getModelFromCache方法的具體用法?PHP XenForo_DataWriter::getModelFromCache怎麽用?PHP XenForo_DataWriter::getModelFromCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XenForo_DataWriter的用法示例。


在下文中一共展示了XenForo_DataWriter::getModelFromCache方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Tinhte_XenTag_execute

 public function Tinhte_XenTag_execute(XenForo_DataWriter $dw)
 {
     if ($dw->isChanged('tags')) {
         return;
     }
     /** @var Tinhte_XenTag_XenForo_DataWriter_Discussion_Thread $dw */
     if (empty($this->_data['actions']['tinhte_xentag'])) {
         return;
     }
     $data = $this->_data['actions']['tinhte_xentag'];
     if (empty($data['remove']) && empty($data['add']) && empty($data['replace']) && empty($data['remove_all'])) {
         return;
     }
     /** @var XenForo_Model_Tag $tagModel */
     $tagModel = $dw->getModelFromCache('XenForo_Model_Tag');
     $tagger = $tagModel->getTagger('thread');
     $tagger->setContent($dw->get('thread_id'))->setPermissionsFromContext($dw->getMergedData(), $dw->Tinhte_XenTag_getForumData());
     if (!empty($data['remove'])) {
         $tagTexts = $tagModel->splitTags($data['remove']);
         $tagger->removeTags($tagTexts, false);
     }
     if (!empty($data['add'])) {
         $tagTexts = $tagModel->splitTags($data['add']);
         $tagger->addTags($tagTexts);
     }
     if (!empty($data['replace'])) {
         $tagTexts = $tagModel->splitTags($data['replace']);
         $tagger->setTags($tagTexts, false);
     } elseif (!empty($data['remove_all'])) {
         $tagger->setTags(array(), false);
     }
     $tagger->save();
 }
開發者ID:maitandat1507,項目名稱:Tinhte_XenTag,代碼行數:33,代碼來源:ThreadAction.php

示例2: verifyPosition

 public static function verifyPosition(&$positions, XenForo_DataWriter $dw, $fieldName = false)
 {
     $positions = trim($positions);
     if (empty($positions)) {
         $dw->error(new XenForo_Phrase('wf_position_can_not_be_empty'), $fieldName);
     }
     if ('all' == $positions) {
         return true;
     }
     /** @var XenForo_Model_Template $templateModel */
     $templateModel = $dw->getModelFromCache('XenForo_Model_Template');
     $db = XenForo_Application::getDb();
     $positionsArray = explode(',', $positions);
     $positionsGood = array();
     $templateForHooks = array();
     foreach ($positionsArray as $position) {
         $position = trim($position);
         if (empty($position)) {
             continue;
         }
         if (in_array($position, array('wf_widget_page', 'hook:wf_widget_page_contents'), true) and !$dw->get('widget_page_id')) {
             $dw->error(new XenForo_Phrase('wf_position_x_requires_widget_page', array('position' => $position)), $fieldName);
             return false;
         }
         if (in_array($position, array('wf_widget_ajax'), true)) {
             $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
             return false;
         }
         // sondh@2012-08-25
         // added support for hook:hook_name
         if (substr($position, 0, 5) == 'hook:') {
             // accept all kind of hooks, just need to get parent templates for them
             $templates = $db->fetchAll("\n\t\t\t\t\tSELECT title\n\t\t\t\t\tFROM `xf_template_compiled`\n\t\t\t\t\tWHERE template_compiled LIKE " . XenForo_Db::quoteLike('callTemplateHook(\'' . substr($position, 5) . '\',', 'lr') . "\n\t\t\t\t");
             if (count($templates) > 0) {
                 $templateForHooks[$position] = array();
                 foreach ($templates as $template) {
                     $templateForHooks[$position][] = $template['title'];
                 }
                 $templateForHooks[$position] = array_unique($templateForHooks[$position]);
             } else {
                 $dw->error(new XenForo_Phrase('wf_non_existent_hook_x', array('hook' => substr($position, 5))), $fieldName);
                 return false;
             }
         } elseif (!$templateModel->getTemplateInStyleByTitle($position)) {
             $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
             return false;
         }
         $positionsGood[] = $position;
     }
     $dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_TEMPLATE_FOR_HOOKS, $templateForHooks);
     asort($positionsGood);
     $positions = implode(', ', $positionsGood);
     return true;
 }
開發者ID:maitandat1507,項目名稱:bdWidgetFramework,代碼行數:54,代碼來源:Widget.php

示例3: verifyMoodId

 /**
  * Verifies that the provided integer is a valid mood ID
  *
  * @param integer $moodId
  * @param XenForo_DataWriter The current running data writer
  * @param string Field being affected
  *
  * @return boolean
  */
 public static function verifyMoodId($moodId, XenForo_DataWriter $dw, $fieldName = false)
 {
     if ($moodId === 0) {
         // explicitly set to 0, use system default
         return true;
     }
     if ($dw->getModelFromCache('XenMoods_Model_Mood')->getMoodById($moodId)) {
         return true;
     }
     $dw->error(new XenForo_Phrase('please_select_valid_mood'), $fieldName);
     return false;
 }
開發者ID:Sywooch,項目名稱:forums,代碼行數:21,代碼來源:Mood.php

示例4: deleteTags

 /**
  * Deletes all tags for specified piece of content.
  *
  * @param string $contentType
  * @param unsigned int $contentId
  * @param XenForo_DataWriter $dw
  */
 public static function deleteTags($contentType, $contentId, XenForo_DataWriter $dw)
 {
     /* @var $tagModel Tinhte_XenTag_Model_Tag */
     $tagModel = $dw->getModelFromCache('Tinhte_XenTag_Model_Tag');
     $existingTags = $tagModel->getTagsOfContent($contentType, $contentId);
     foreach ($existingTags as $tag) {
         /* @var $dwTag Tinhte_XenTag_DataWriter_Tagged */
         $dwTagged = XenForo_DataWriter::create('Tinhte_XenTag_DataWriter_TaggedContent');
         $data = array('tag_id' => $tag['tag_id'], 'content_type' => $contentType, 'content_id' => $contentId);
         $dwTagged->setExistingData($data, true);
         $dwTagged->delete();
     }
     return count($existingTags);
 }
開發者ID:Sywooch,項目名稱:forums,代碼行數:21,代碼來源:Integration.php

示例5: verifyPosition

 public static function verifyPosition(&$positions, XenForo_DataWriter $dw, $fieldName = false)
 {
     if ($dw->get('widget_page_id') > 0) {
         if ($positions === 'sidebar') {
             // good
         } else {
             $positions = '';
         }
         return true;
     }
     // sondh@2012-08-28
     // it may be better to use strtolower with $positions (making it easier for
     // admins)
     // but some add-on developers decided to use template with mixed case characters
     // so...
     // no strtolower goodness for everyone.
     $positions = trim($positions);
     if (empty($positions)) {
         $dw->error(new XenForo_Phrase('wf_position_can_not_be_empty'), $fieldName);
     }
     if ('all' == $positions) {
         return true;
     }
     $templateModel = $dw->getModelFromCache('XenForo_Model_Template');
     $db = XenForo_Application::getDb();
     $positionsArray = explode(',', $positions);
     $positionsGood = array();
     $templateForHooks = array();
     foreach ($positionsArray as $position) {
         $position = trim($position);
         if (empty($position)) {
             continue;
         }
         // sondh@2012-08-25
         // added support for hook:hook_name
         if (substr($position, 0, 5) == 'hook:') {
             // accept all kind of hooks, just need to get parent templates for them
             $templates = $db->fetchAll("\n\t\t\t\t\tSELECT title\n\t\t\t\t\tFROM `xf_template_compiled`\n\t\t\t\t\tWHERE template_compiled LIKE " . XenForo_Db::quoteLike('callTemplateHook(\'' . substr($position, 5) . '\',', 'lr') . "\n\t\t\t\t");
             if (count($templates) > 0) {
                 $templateForHooks[$position] = array();
                 foreach ($templates as $template) {
                     $templateForHooks[$position][] = $template['title'];
                 }
                 $templateForHooks[$position] = array_unique($templateForHooks[$position]);
             } else {
                 $dw->error(new XenForo_Phrase('wf_non_existent_hook_x', array('hook' => substr($position, 5))), $fieldName);
                 return false;
             }
         } else {
             $found = $templateModel->getTemplateInStyleByTitle($position);
             if (!$found) {
                 $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
                 return false;
             }
         }
         $positionsGood[] = $position;
     }
     $dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_TEMPLATE_FOR_HOOKS, $templateForHooks);
     asort($positionsGood);
     $positions = implode(', ', $positionsGood);
     return true;
 }
開發者ID:Sywooch,項目名稱:forums,代碼行數:62,代碼來源:Widget.php


注:本文中的XenForo_DataWriter::getModelFromCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。