- Timestamp:
- 10/01/08 03:41:41 (2 months ago)
- Location:
- events/phpframework/sabel/trunk
- Files:
-
- 4 added
- 24 modified
-
PHWITTR.TXT (modified) (1 diff)
-
Sabel/sabel/Context.php (modified) (2 diffs)
-
Sabel/sabel/ValueObject.php (modified) (1 diff)
-
addon/renderer/sabel/Replacer.php (modified) (1 diff)
-
app/aspects/Transaction.php (modified) (1 diff)
-
app/aspects/UserCache.php (added)
-
app/controllers/Application.php (modified) (1 diff)
-
app/helpers/application.php (modified) (1 diff)
-
app/index/controllers/Friendship.php (modified) (2 diffs)
-
app/index/controllers/Index.php (modified) (3 diffs)
-
app/index/controllers/Status.php (modified) (1 diff)
-
app/index/controllers/User.php (modified) (1 diff)
-
app/index/controllers/Users.php (modified) (1 diff)
-
app/logics/DI.php (modified) (1 diff)
-
app/logics/Follow.php (modified) (7 diffs)
-
app/logics/Status.php (modified) (2 diffs)
-
app/models/Status.php (modified) (2 diffs)
-
app/views/Submenu.php (added)
-
app/views/layout.tpl (modified) (1 diff)
-
app/views/submenu/others.tpl (modified) (1 diff)
-
app/views/submenu/user.tpl (modified) (2 diffs)
-
cache/user (added)
-
config/DI.php (modified) (1 diff)
-
config/environment.php (modified) (1 diff)
-
lib/AjaxResult.php (modified) (1 diff)
-
lib/UserCache.php (added)
-
lib/processor/Action.php (modified) (1 diff)
-
lib/processor/View.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/sabel/trunk/PHWITTR.TXT
r20153 r20329 30 30 31 31 運用時はENVIRONMENTをPRODUCTIONにしてください 32 33 * PRODUCTIONではテンプレートや一部のデータがキャッシュされます 34 テンプレートを修正した場合は'cache/templates/'の下を削除してください 35 データベースのデータを直接変更した場合は'cache/user/'の下を削除してください 32 36 33 37 ================================================================================ -
events/phpframework/sabel/trunk/Sabel/sabel/Context.php
r20236 r20329 68 68 } 69 69 70 public static function getResponse() 71 { 72 $context = self::getContext(); 73 return ($context->bus) ? $context->bus->get("response") : null; 74 } 75 70 76 public static function getDestination() 71 77 { … … 86 92 } 87 93 88 public static function get Response()94 public static function getView() 89 95 { 90 96 $context = self::getContext(); 91 return ($context->bus) ? $context->bus->get(" response") : null;97 return ($context->bus) ? $context->bus->get("view") : null; 92 98 } 93 99 } -
events/phpframework/sabel/trunk/Sabel/sabel/ValueObject.php
r20063 r20329 86 86 throw new Sabel_Exception_InvalidArgument($message); 87 87 } 88 89 return $this; 88 90 } 89 91 } -
events/phpframework/sabel/trunk/addon/renderer/sabel/Replacer.php
r20065 r20329 174 174 } else { 175 175 $fmt = '<?php echo $this->partial("%s", %s) ?>'; 176 $assign = preg_match_replace("/'. +[^\\\\]'/U", ",", "_%CMM%_", $assign);176 $assign = preg_match_replace("/'.*[^\\\\]'/U", ",", "_%CMM%_", $assign); 177 177 $assigns = explode(",", $assign); 178 178 if (strpos($assigns[0], ":") === false) { -
events/phpframework/sabel/trunk/app/aspects/Transaction.php
r20065 r20329 8 8 9 9 try { 10 l("before: transaction"); 10 11 $result = $inv->proceed(); 12 l("after: transaction"); 11 13 Sabel_Db_Transaction::commit(); 12 14 return $result; -
events/phpframework/sabel/trunk/app/controllers/Application.php
r20073 r20329 24 24 $aclUser->isProtected = $aUser->isProtected(); 25 25 } 26 27 protected function assignUserSubmenu()28 {29 $user = $this->aclUser;30 $userData = $this->getUserData($user->id);31 32 if ($user->isProtected) {33 $userData->requestCount = Request::getRequestsCount($user->id);34 }35 36 $userData->name = $user->name;37 $userData->image = $user->image;38 $userData->latestComment = Status::getLatestCommentByUserId($user->id);39 40 $renderer = $this->view->getRenderer();41 $contents = file_get_contents(42 MODULES_DIR_PATH . DS . VIEW_DIR_NAME . DS . "submenu" . DS . "user.tpl"43 );44 45 $this->submenuHtml = $renderer->rendering($contents, array("userData" => $userData));46 }47 48 protected function assignOthersSubmenu($userId, $userName = null)49 {50 $userData = $this->getUserData($userId);51 52 if ($userName === null) {53 $aUser = new User($userId);54 $userData->name = $aUser->user_name;55 } else {56 $userData->name = $userName;57 }58 59 $renderer = $this->view->getRenderer();60 $contents = file_get_contents(61 MODULES_DIR_PATH . DS . VIEW_DIR_NAME . DS . "submenu" . DS . "others.tpl"62 );63 64 $this->submenuHtml = $renderer->rendering($contents, array("userData" => $userData));65 }66 67 private function getUserData($userId)68 {69 return Sabel_ValueObject::fromArray(array(70 "userId" => $userId,71 "friends" => Follower::getFriends($userId, FRIENDS_ICON_LIMIT + 1),72 "friendsCount" => Follower::getFriendsCount($userId),73 "followersCount" => Follower::getFollowersCount($userId),74 "statusesCount" => Status::getCountByUserId($userId)75 ));76 }77 26 } -
events/phpframework/sabel/trunk/app/helpers/application.php
r20238 r20329 67 67 } 68 68 69 /*70 function to_date($date, $format)71 {72 return Helpers_Date::format($date, constant("Helpers_Date::" . $format));73 }74 75 function __include($uri, $values = array(), $method = Sabel_Request::GET, $withLayout = false)76 {77 $requester = new Sabel_Request_Internal($method);78 $requester->values($values)->withLayout($withLayout);79 return $requester->request($uri)->getResult();80 }81 */82 83 69 function datetime($date, $format = "m/d H:i") 84 70 { -
events/phpframework/sabel/trunk/app/index/controllers/Friendship.php
r20073 r20329 46 46 47 47 if ($success) { 48 $aUser = new User($this->id); 49 $this->redirect->to("n: users, c: {$aUser->user_name}, a: "); 48 if (!$this->isAjaxRequest()) { 49 $aUser = new User($this->id); 50 $this->redirect->to("n: users, c: {$aUser->user_name}, a: "); 51 } 50 52 } else { 51 53 $this->badRequest(); … … 55 57 public function requests() 56 58 { 57 $this-> assignUserSubmenu();59 $this->submenu->setUser($this->aclUser->id); 58 60 $this->requests = Request::getRequestsByUserId($this->aclUser->id); 59 61 -
events/phpframework/sabel/trunk/app/index/controllers/Index.php
r20238 r20329 12 12 public function timeline() 13 13 { 14 // これしょぼす 14 15 $this->rsslink = '<link rel="alternate" type="application/rss+xml" ' 15 16 . 'title="Phwittr public timeline" ' … … 22 23 $this->clientId = $this->session->getClientId(); 23 24 $this->isProtected = $this->aclUser->isProtected; 24 $this-> assignUserSubmenu();25 $this->submenu->setUser($this->aclUser->id); 25 26 } 26 27 } … … 73 74 74 75 if ($isSelf) { 75 $this-> assignUserSubmenu();76 $this->submenu->setUser($this->aclUser->id); 76 77 } else { 77 $this-> assignOthersSubmenu($aUser->id, $aUser->name);78 $this->submenu->setUser($aUser->id, Views_Submenu::TYPE_OTHERS); 78 79 } 79 80 } -
events/phpframework/sabel/trunk/app/index/controllers/Status.php
r20065 r20329 45 45 $this->badRequest(); 46 46 } else { 47 $aStatus = new Status($this->param); 48 if ($aStatus->user_id === $this->aclUser->id) { 49 $aStatus->delete(); 50 } 47 $this->getLogic("status")->remove($this->aclUser->id, $this->param); 51 48 } 52 49 } -
events/phpframework/sabel/trunk/app/index/controllers/User.php
r20153 r20329 11 11 { 12 12 if ($this->response->isSuccess() && $this->action !== "logout") { 13 $this-> assignUserSubmenu();13 $this->submenu->setUser($this->aclUser->id); 14 14 } 15 15 } -
events/phpframework/sabel/trunk/app/index/controllers/Users.php
r20238 r20329 10 10 if ($this->aUser = $this->fetchModel("User", array("user_name" => $parts[0]))) { 11 11 if ($this->aUser->isActive()) { 12 $this-> assignOthersSubmenu($this->aUser->id, $this->aUser->name);12 $this->submenu->setUser($this->aUser->id, Views_Submenu::TYPE_OTHERS); 13 13 } else { 14 14 $this->notFound(); -
events/phpframework/sabel/trunk/app/logics/DI.php
r20074 r20329 11 11 } 12 12 13 $this->aspect("Logics_Base")->annotate( 14 "transaction", array("Aspects_Transaction") 15 ); 13 if (ENVIRONMENT === PRODUCTION) { 14 $this->bind("Mail")->to("Mail_Object"); 15 } else { 16 $this->bind("Mail")->to("Mail_Mock"); 17 } 18 19 $aspect = $this->aspect("Logics_Base"); 20 $aspect->annotate("transaction", array("Aspects_Transaction")); 21 22 if ((ENVIRONMENT & PRODUCTION) > 0) { 23 $aspect->annotate("userCache", array("Aspects_UserCache")); 24 } 16 25 } 17 26 } -
events/phpframework/sabel/trunk/app/logics/Follow.php
r20074 r20329 4 4 { 5 5 /** 6 * @userCache 7 * 6 8 * @param int $userId ユーザID 7 9 * @param int $targetId フォローするユーザのID … … 23 25 "created_at" => now() 24 26 )); 27 28 $result->addType = "request"; 25 29 } else { 26 30 $follower = new Follower(); … … 30 34 "created_at" => now() 31 35 )); 36 37 $result->addType = "follow"; 32 38 } 33 39 } else { … … 39 45 40 46 /** 47 * @userCache 48 * 41 49 * @param int $userId ユーザID 42 50 * @param int $targetId フォロー中ユーザのID … … 56 64 $request->setCondition("request_id", $targetId); 57 65 $request->delete(); 66 $result->removeType = "request"; 58 67 } else { 59 68 $follower = new Follower(); … … 61 70 $follower->setCondition("follow_id", $targetId); 62 71 $follower->delete(); 72 $result->removeType = "follow"; 63 73 } 64 74 } else { … … 71 81 /** 72 82 * @transaction 83 * @userCache 73 84 * 74 85 * @param int $userId リクエストされたユーザのID -
events/phpframework/sabel/trunk/app/logics/Status.php
r20074 r20329 5 5 /** 6 6 * @transaction 7 * @userCache 7 8 * 8 9 * @param int $userId ユーザID … … 34 35 return $result; 35 36 } 37 38 /** 39 * @userCache 40 * 41 * @param int $userId ユーザID 42 * @param int $statusId ステータスID 43 * 44 * @return Logics_Result 45 */ 46 public function remove($userId, $statusId) 47 { 48 $result = new Logics_Result(); 49 $aStatus = new Status($statusId); 50 51 if ($aStatus->isSelected() && $aStatus->user_id === $userId) { 52 $aStatus->delete(); 53 } else { 54 $result->failure(); 55 } 56 57 return $result; 58 } 36 59 } -
events/phpframework/sabel/trunk/app/models/Status.php
r20073 r20329 8 8 { 9 9 $status = new self(); 10 $status->setProjection(array("comment")); 10 11 $status->setCondition("user_id", $userId); 11 12 $status->setOrderBy("created_at", "desc"); … … 13 14 14 15 $statuses = $status->select(); 15 return (isset($statuses[0])) ? $statuses[0] : null;16 return (isset($statuses[0])) ? $statuses[0]->comment : ""; 16 17 } 17 18 -
events/phpframework/sabel/trunk/app/views/layout.tpl
r20065 r20329 42 42 43 43 <div id="subMenu"> 44 <if isset="$submenuHtml"> 45 <?e $submenuHtml ?> 46 <else /> 47 <partial name="submenu/default" /> 48 </if> 44 <?e $submenuHtml ?> 49 45 50 46 <p class="poweredBy"> -
events/phpframework/sabel/trunk/app/views/submenu/others.tpl
r20074 r20329 30 30 </ul> 31 31 32 <? $ uri = uri("n: users, c: {$userData->name}, a: friends") ?>33 <partial name="submenu/_friendIcons" assign="userData: $userData, toAllFriends: $ uri" />32 <? $_uri = uri("n: users, c: {$userData->name}, a: friends") ?> 33 <partial name="submenu/_friendIcons" assign="userData: $userData, toAllFriends: $_uri" /> -
events/phpframework/sabel/trunk/app/views/submenu/user.tpl
r20065 r20329 17 17 <p id="latestComment"> 18 18 <if expr="$userData->latestComment"> 19 <?e $userData->latestComment ->comment|showComment ?>19 <?e $userData->latestComment|showComment ?> 20 20 </if> 21 21 </p> … … 38 38 </ul> 39 39 40 <? $ uri = uri("n: default, c: user, a: friends") ?>41 <partial name="submenu/_friendIcons" assign="userData: $userData, toAllFriends: $ uri" />40 <? $_uri = uri("n: default, c: user, a: friends") ?> 41 <partial name="submenu/_friendIcons" assign="userData: $userData, toAllFriends: $_uri" /> -
events/phpframework/sabel/trunk/config/DI.php
r20065 r20329 5 5 public function configure() 6 6 { 7 if (ENVIRONMENT === PRODUCTION) { 8 $this->bind("Mail")->to("Mail_Object"); 9 } else { 10 $this->bind("Mail")->to("Mail_Mock"); 11 } 7 12 8 } 13 9 } -
events/phpframework/sabel/trunk/config/environment.php
r20065 r20329 4 4 * define sabel environment. 5 5 */ 6 //if (!defined("ENVIRONMENT")) define("ENVIRONMENT", PRODUCTION);6 if (!defined("ENVIRONMENT")) define("ENVIRONMENT", PRODUCTION); 7 7 // if (!defined("ENVIRONMENT")) define("ENVIRONMENT", BENCHMARK); 8 8 // if (!defined("ENVIRONMENT")) define("ENVIRONMENT", TEST); -
events/phpframework/sabel/trunk/lib/AjaxResult.php
r20065 r20329 6 6 { 7 7 $this->success(); 8 9 $this->useTemplate = false; 8 10 } 9 11 -
events/phpframework/sabel/trunk/lib/processor/Action.php
r20238 r20329 27 27 $controller->setAttribute("ajax", new AjaxResult()); 28 28 } 29 30 $controller->setAttribute("submenu", new Views_Submenu()); 29 31 30 32 try { -
events/phpframework/sabel/trunk/lib/processor/View.php
r20238 r20329 46 46 if ($response->isRedirected()) return; 47 47 48 $controller = $bus->get("controller"); 49 $responses = $response->getResponses(); 50 $contents = (isset($responses["contents"])) ? $responses["contents"] : ""; 48 $responses = $response->getResponses(); 49 $contents = (isset($responses["contents"])) ? $responses["contents"] : ""; 51 50 52 51 $isAjax = $bus->get("AJAX_REQUEST"); 53 54 // @todo... 55 if ($isAjax && isset($responses["ajax"])) { 52 if ($isAjax && isset($responses["ajax"]) && !$responses["ajax"]->useTemplate) { 56 53 return $bus->set("result", $responses["ajax"]->toString()); 57 54 } … … 62 59 if ($location = $view->getValidLocation()) { 63 60 $contents = $view->rendering($location, $responses); 64 } elseif (!$ controller->isExecuted()) {61 } elseif (!$bus->get("controller")->isExecuted()) { 65 62 $response->getStatus()->setCode(Sabel_Response::NOT_FOUND); 66 63 if ($location = $view->getValidLocation("notFound")) { … … 75 72 $bus->set("result", $contents); 76 73 } else { 77 $layout = DEFAULT_LAYOUT_NAME;78 74 if ($response->isFailure()) { 79 75 $layout = "noColumnLayout"; 80 } elseif (isset($responses["layout"])) { 81 $layout = $responses["layout"]; 76 } else { 77 $layout = (isset($responses["layout"])) ? $responses["layout"] : DEFAULT_LAYOUT_NAME; 78 if (isset($responses["submenu"])) { 79 $submenu = $responses["submenu"]; 80 $responses["submenuHtml"] = $submenu->merge($responses)->rendering($view->getRenderer());; 81 } 82 82 } 83 83
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)