コード例 #1
0
 /**
  * Renders and returns string content of summary content for the given model.
  * @param RedBeanModel $model
  * @param mixed $redirectUrl
  * @param string $ownedByFilter
  * @param string $viewModuleClassName
  * @return string content
  */
 public static function renderSummaryContent(RedBeanModel $model, $redirectUrl, $ownedByFilter, $viewModuleClassName)
 {
     assert('is_string($redirectUrl) || $redirectUrl == null');
     assert('is_string($ownedByFilter)');
     assert('is_string($viewModuleClassName)');
     $mashableActivityRules = MashableActivityRulesFactory::createMashableActivityRulesByModel(get_class($model));
     $orderByAttributeName = $mashableActivityRules->getLatestActivitiesOrderByAttributeName();
     $summaryContentTemplate = $mashableActivityRules->getSummaryContentTemplate($ownedByFilter, $viewModuleClassName);
     $content = '<div class="activity-item">';
     //Render icon
     $content .= '<em class="' . get_class($model) . '"></em>';
     //Render date
     $content .= '<strong class="activity-date">' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($model->{$orderByAttributeName}, 'long', null) . '</strong>';
     $data = array();
     $data['modelStringContent'] = self::renderModelStringContent($model, $redirectUrl);
     $data['ownerStringContent'] = self::renderOwnerStringContent($model);
     $data['relatedModelsByImportanceContent'] = $mashableActivityRules->renderRelatedModelsByImportanceContent($model);
     $data['extraContent'] = self::resolveAndRenderExtraContent($model, $mashableActivityRules);
     //Render display content
     $content .= self::resolveContentTemplate($summaryContentTemplate, $data);
     $content .= '</div>';
     return $content;
 }
コード例 #2
0
 /**
  * Given an array of modelClassNames build an array of sortAttributeData that
  * can be used by the RedBeanModelsDataProvider to produce a union query of data.
  * @param array $modelClassNames
  * @return array $modelClassNamesAndSortAttributes
  */
 public static function getSortAttributesByMashableModelClassNames($modelClassNames)
 {
     $modelClassNamesAndSortAttributes = array();
     foreach ($modelClassNames as $modelClassName) {
         $mashableActivityRules = MashableActivityRulesFactory::createMashableActivityRulesByModel($modelClassName);
         $modelClassNamesAndSortAttributes[$modelClassName] = $mashableActivityRules->getLatestActivitiesOrderByAttributeName();
     }
     return $modelClassNamesAndSortAttributes;
 }