/** * Método que despacha la página solicitada * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) * @version 2014-03-21 */ public static function dispatch() { $request = new Network_Request(); $response = new Network_Response(); // Verificar si el recurso solicitado es un archivo físico dentro del // directorio webroot if (self::_asset($request->request, $response)) { // retorna el método Dispatcher::dispatch, con lo cual termina el // procesado de la página return; } // Parsear parámetros del request $request->params = Routing_Router::parse($request->request); // Si se solicita un módulo tratar de cargar y verificar que quede activo if (!empty($request->params['module'])) { Module::load($request->params['module']); if (!Module::loaded($request->params['module'])) { throw new Exception_Module_Missing(array('module' => $request->params['module'])); } } // Obtener controlador $controller = self::_getController($request, $response); // Verificar que lo obtenido sea una instancia de la clase Controller if (!$controller instanceof Controller) { throw new Exception_Controller_Missing(array('class' => 'Controller_' . Utility_Inflector::camelize($request->params['controller']))); } // Invocar a la acción del controlador return self::_invoke($controller, $request, $response); }
public static function _init() { if (\Module::loaded('timeline')) { // album_image 追加時に note の sort_datetime を更新 static::$_observers['MyOrm\\Observer_UpdateRelationalTables'] = array('events' => array('after_insert'), 'relations' => array('model_to' => '\\Note\\Model_Note', 'conditions' => array('id' => array('note_id' => 'property')), 'update_properties' => array('sort_datetime' => array('created_at' => 'property')))); } }
function is_enabled($module_name) { if (!Module::loaded($module_name)) { return false; } if (!conf($module_name . '.isEnabled')) { return false; } return true; }
public static function _init() { if (\Module::loaded('timeline')) { static::$_observers['MyOrm\\Observer_InsertMemberFollowTimeline'] = array('events' => array('after_insert'), 'timeline_relations' => array('foreign_table' => array('note' => 'value'), 'foreign_id' => array('note_id' => 'property')), 'property_from_member_id' => 'member_id'); } if (is_enabled('notice')) { static::$_observers['MyOrm\\Observer_InsertNotice'] = array('events' => array('after_insert'), 'update_properties' => array('foreign_table' => array('note' => 'value'), 'foreign_id' => array('note_id' => 'property'), 'type_key' => array('like' => 'value'), 'member_id_from' => array('member_id' => 'property'), 'member_id_to' => array('related' => array('note' => 'member_id')))); $type = \Notice\Site_Util::get_notice_type('like'); static::$_observers['MyOrm\\Observer_DeleteNotice'] = array('events' => array('before_delete'), 'conditions' => array('foreign_table' => array('note' => 'value'), 'foreign_id' => array('note_id' => 'property'), 'type' => array($type => 'value'))); } }
public static function merge_module_configs($config, $config_name) { $modules = Module::loaded(); foreach ($modules as $module => $path) { Config::load($module . '::' . $config_name, $module . '_' . $config_name); if (!($module_config = Config::get($module . '_' . $config_name))) { continue; } $config = Arr::merge_assoc($config, $module_config); } return $config; }
public function update_public_flag_with_relations($public_flag, $is_update_album_images = false) { // album_image の public_flag の更新 if ($is_update_album_images) { Model_AlbumImage::update_public_flag4album_id($this->id, $public_flag); } // timeline の public_flag の更新 if (\Module::loaded('timeline')) { \Timeline\Model_Timeline::update_public_flag4foreign_table_and_foreign_id($public_flag, 'album', $this->id, \Config::get('timeline.types.album')); } $this->public_flag = $public_flag; $this->save(); }
public static function force_save_album($member_id, $values, Model_Album $album = null) { // album save if (!$album) { $album = Model_Album::forge(); } $album->name = $values['name']; $album->body = $values['body']; $album->public_flag = $values['public_flag']; $album->member_id = $member_id; $album->save(); if (\Module::loaded('timeline')) { \Timeline\Site_Model::save_timeline($member_id, $values['public_flag'], 'album', $album->id, $album->updated_at); } return $album; }
public function action_index() { //$testModel = Model_Sales_Disposition::test(); /* if (\Reports\Query::forge(\Reports\Query::LOAD, 3)->isComplete()) { print_r('complete'); } */ // Load the required data module if (!\Module::loaded('data') && \Module::exists('data')) { \Module::load('data'); } else { throw new \Exception("Data Module not found!"); } $impData = \Data\Import::forge(\Data\Import::COPY, 1); $this->template->title = 'Example Page'; $this->template->content = "hello"; }
/** * Usage (from command line): * * php oil r setupmodule * * @return string */ public static function run($target_module = null) { $is_execued = false; try { $modules = $target_module ? (array) $target_module : \Module::loaded(); if (!$modules) { return; } foreach ($modules as $module => $module_dir_path) { if ($messages = self::setup_assets($module, $module_dir_path)) { foreach ($messages as $message) { echo $message . PHP_EOL; } $is_execued = true; } } } catch (\FuelException $e) { return \Util_Task::output_message(sprintf('Setup modules error: %s', $e->getMessage()), false); } return $is_execued ? \Util_Task::output_result_message(true, 'setup modules') : ''; }
public static function get_active_modules() { $active_modules = array(); $modules = Module::loaded(); foreach ($modules as $module => $module_path) { if (!conf($module . '.isEnabled')) { continue; } $active_modules[$module] = $module_path; } return $active_modules; }
private static function exexute_install_db($database = null) { $setup_sql_file = sprintf('%sdata/sql/setup/setup%s.sql', FBD_BASEPATH, self::$charset == 'utf8mb4' ? '_utf8mb4' : ''); if (!\DBUtil::shell_exec_sql4file($setup_sql_file, $database)) { return false; } if (!($modules = \Module::loaded())) { return true; } foreach ($modules as $module => $path) { $setup_sql_file = $path . 'data/sql/setup/setup.sql'; if (!file_exists($setup_sql_file)) { continue; } if (!\DBUtil::shell_exec_sql4file($setup_sql_file, $database)) { return false; } } return true; }
<div class="article_body"> <?php echo convert_body($note->body, array('is_truncate' => false)); ?> </div> <?php if (Module::loaded('album')) { echo render('album::image/_parts/list', array('list' => $images, 'is_simple_view' => true)); } ?> <?php if ($note->is_published) { ?> <div class="comment_info"> <?php // comment_count_and_link echo render('_parts/comment/count_and_link_display', array('id' => $note->id, 'count' => $all_comment_count, 'link_hide_absolute' => true)); ?> <?php // like_count_and_link if (conf('like.isEnabled') && Auth::check()) { $data_like_link = array('id' => $note->id, 'post_uri' => \Site_Util::get_api_uri_update_like('note', $note->id), 'get_member_uri' => \Site_Util::get_api_uri_get_liked_members('note', $note->id), 'count_attr' => array('class' => 'unset_like_count'), 'count' => $note->like_count, 'is_liked' => $is_liked_self); echo render('_parts/like/count_and_link_execute', $data_like_link); } ?> <?php // Facebook feed
<?php echo render('_parts/member_contents_box', array('member' => $note->member, 'model' => 'note', 'id' => $id, 'size' => 'M', 'public_flag' => $note->public_flag, 'date' => array('datetime' => $note->published_at ? $note->published_at : $note->updated_at))); $dropdown_btn_group_attr = array('id' => 'btn_dropdown_' . $id, 'class' => array('dropdown', 'boxBtn')); $dropdown_btn_attr = array('class' => 'js-dropdown_content_menu', 'data-uri' => sprintf('note/api/menu/%d.html', $id), 'data-member_id' => $note->member_id, 'data-menu' => '#menu_' . $note->id, 'data-loaded' => 0); $menus = array(array('icon_term' => 'site.show_detail', 'href' => 'note/' . $id)); echo btn_dropdown('noterm.dropdown', $menus, false, 'xs', null, true, $dropdown_btn_group_attr, $dropdown_btn_attr, false); ?> </div><!-- list_subtitle --> </div><!-- header --> <div class="body"> <?php echo convert_body($note->body, array('truncate_line' => conf('view_params_default.list.truncate_lines.body'), 'read_more_uri' => 'note/' . $id)); ?> </div> <?php if (Module::loaded('album') && ($images = \Note\Model_NoteAlbumImage::get_album_image4note_id($id, 4, array('id' => 'desc')))) { echo render('_parts/thumbnails', array('images' => array('list' => $images, 'additional_table' => 'note', 'size' => 'N_M', 'column_count' => 4), 'is_modal_link' => conf('site.common.thumbnailModalLink.isEnabled', 'page'))); } ?> <?php if ($note->is_published) { // note_comment list($comments, $comment_next_id, $all_comment_count) = \Note\Model_NoteComment::get_list(array('note_id' => $id), conf('view_params_default.list.comment.limit'), true, false, 0, 0, null, false, true); ?> <div class="comment_info"> <?php // comment_count_and_link $link_comment_attr = array('id' => 'link_show_comment_form_' . $id, 'class' => 'js-display_parts link_show_comment_' . $id, 'data-target_id' => 'commentPostBox_' . $id, 'data-hide_selector' => '.link_show_comment_' . $id, 'data-focus_selector' => '#textarea_comment_' . $id); echo render('_parts/comment/count_and_link_display', array('id' => $id, 'count' => $all_comment_count, 'link_attr' => $link_comment_attr));
public static function save_with_relations($album_id, \Model_Member $member = null, $public_flag = null, $file_path = null, $timeline_type_key = 'album_image', $optional_values = array()) { if (!\Util_Array::array_in_array(array_keys($optional_values), array('name', 'shot_at', 'shot_at_time', 'public_flag'))) { throw new \InvalidArgumentException('Parameter optional_values is invalid.'); } if (is_null($public_flag)) { $public_flag = isset($optional_values['public_flag']) ? $optional_values['public_flag'] : conf('public_flag.default'); } $album = null; if (empty($member)) { $album = Model_Album::find($album_id, array('related' => 'member')); $member = $album->member; } $options = \Site_Upload::get_uploader_options($member->id, 'ai', $album_id); $uploadhandler = new \Site_Uploader($options); $file = $uploadhandler->save($file_path); if (!empty($file->error)) { throw new \FuelException($file->error); } $self = new self(); $self->album_id = $album_id; $self->file_name = $file->name; $self->public_flag = $public_flag; $self->shot_at = self::get_shot_at_for_insert($file->shot_at, isset($optional_values['shot_at_time']) ? $optional_values['shot_at_time'] : null, isset($optional_values['shot_at']) ? $optional_values['shot_at'] : null); $self->save(); // カバー写真の更新 if ($timeline_type_key == 'album_image_profile') { if (!$album) { $album = Model_Album::find($album_id); } $album->cover_album_image_id = $self->id; $album->save(); } // timeline 投稿 if (\Module::loaded('timeline')) { switch ($timeline_type_key) { case 'album_image_profile': $timeline_foreign_id = $self->id; $timeline_child_foreign_ids = array(); break; case 'album': case 'album_image': default: $timeline_foreign_id = $self->album->id; $timeline_child_foreign_ids = array($self->id); break; } \Timeline\Site_Model::save_timeline($member->id, $public_flag, $timeline_type_key, $timeline_foreign_id, $self->updated_at, null, null, $timeline_child_foreign_ids); } return array($self, $file); }
<a href="<?php echo Uri::Create('user'); ?> ">Dashboard</a> </li> <li <?php echo Uri::Current() == Uri::Create('user/urls') ? 'class="active"' : ''; ?> > <a href="<?php echo Uri::Create('user/urls'); ?> ">My URLs</a> </li> <?php if (Module::loaded('image') === true) { ?> <li <?php echo Uri::Current() == Uri::Create('user/images') ? 'class="active"' : ''; ?> > <a href="<?php echo Uri::Create('user/images'); ?> ">My Images</a> </li> <?php } ?> <?php if (Auth::member(5)) {
/** * Album upload * @access public * @params integer * @return Response */ public function action_upload($id = null) { $id = (int) $id; $album = Model_Album::check_authority($id, $this->u->id, 'member'); if (Site_Util::check_album_disabled_to_update($album->foreign_table, true)) { throw new \HttpForbiddenException(); } $files = array(); if (\Input::method() == 'POST') { \Util_security::check_csrf(); $file_tmps = array(); $moved_files = array(); try { //if (!$val->run()) throw new \FuelException($val->show_errors()); $file_tmps = \Site_FileTmp::get_file_tmps_uploaded($this->u->id, true); \Site_FileTmp::check_uploaded_under_accepted_filesize($file_tmps, $this->u->filesize_total, \Site_Upload::get_accepted_filesize()); \DB::start_transaction(); list($moved_files, $album_image_ids) = \Site_FileTmp::save_images($file_tmps, $album->id, 'album_id', 'album_image', $album->public_flag); if (\Module::loaded('timeline')) { \Timeline\Site_Model::save_timeline($this->u->id, $album->public_flag, 'album_image', $album->id, null, null, null, $album_image_ids); } \DB::commit_transaction(); // thumbnail 作成 & tmp_file thumbnail 削除 \Site_FileTmp::make_and_remove_thumbnails($moved_files); $message = sprintf('%sをアップロードしました。', term('album_image')); \Session::set_flash('message', $message); $redirect_uri = 'album/detail/' . $album->id; if (FBD_FACEBOOK_APP_ID && conf('service.facebook.shareDialog.album.isEnabled') && conf('service.facebook.shareDialog.album.autoPopupAfterUploaded')) { $redirect_uri .= '?created=1'; } \Response::redirect($redirect_uri); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } if ($moved_files) { \Site_FileTmp::move_files_to_tmp_dir($moved_files); } $files = \Site_FileTmp::get_file_objects($file_tmps, $this->u->id); \Session::set_flash('error', $e->getMessage()); } } $this->template->post_header = \View::forge('filetmp/_parts/upload_header'); $this->template->post_footer = \View::forge('_parts/form/upload_footer'); $this->set_title_and_breadcrumbs(term('album_image', 'form.upload'), array('/album/' . $id => $album->name), $album->member, 'album'); $this->template->content = \View::forge('_parts/form/upload', array('id' => $id, 'album' => $album, 'files' => $files)); }
private static function force_save_album($member_id, $values, Model_Album $album = null) { // album save if (!$album) { $album = Model_Album::forge(); } $album->name = $values['name']; $album->body = $values['body']; $album->public_flag = $values['public_flag']; $album->member_id = $member_id; $album->save(); if (\Module::loaded('timeline')) { \Timeline\Site_Model::save_timeline($member_id, $values['public_flag'], 'album_image', $album->id, $album->updated_at); } //list($album, $moved_files, $is_changed) = Model_Album::save_with_relations($values, $member_id, $album); //// album_image save //$member = \Model_Member::check_authority($member_id); //list($album_image, $file) = Model_AlbumImage::save_with_relations($album->id, $member, $values['public_flag'], $upload_file_path, 'album'); return $album; }
public function delete_with_relations() { // album_image の削除 if (\Module::loaded('album') && ($album_images = Model_NoteAlbumImage::get_album_image4note_id($this->id))) { $album_image_ids = array(); foreach ($album_images as $album_image) { $album_image_ids[] = $album_image->id; } \Album\Model_AlbumImage::delete_multiple($album_image_ids); } // timeline 投稿の削除 if (\Module::loaded('timeline')) { \Timeline\Model_Timeline::delete4foreign_table_and_foreign_ids('note', $this->id); } // note の削除 $this->delete(); }
/** * Locates a given file in the search paths. * * @param string $dir Directory to look in * @param string $file File to find * @param string $ext File extension * @param bool $multiple Whether to find multiple files * @param bool $cache Whether to cache this path or not * @return mixed Path, or paths, or false */ public function locate($dir, $file, $ext = '.php', $multiple = false, $cache = true) { $found = $multiple ? array() : false; // absolute path requested? if ($file[0] === '/' or substr($file, 1, 2) === ':\\') { // if the base file does not exist, stick the extension to the back of it if (!is_file($file)) { $file .= $ext; } if (!is_file($file)) { // at this point, found would be either empty array or false return $found; } return $multiple ? array($file) : $file; } // determine the cache prefix if ($multiple) { // make sure cache is not used if the loaded package and module list is changed $cachekey = ''; class_exists('Module', false) and $cachekey .= implode('|', \Module::loaded()); $cachekey .= '|'; class_exists('Package', false) and $cachekey .= implode('|', \Package::loaded()); $cache_id = md5($cachekey) . '.'; } else { $cache_id = 'S.'; } $paths = array(); // If a filename contains a :: then it is trying to be found in a namespace. // This is sometimes used to load a view from a non-loaded module. if ($pos = strripos($file, '::')) { // get the namespace path if ($path = \Autoloader::namespace_path('\\' . ucfirst(substr($file, 0, $pos)))) { $cache_id .= substr($file, 0, $pos); // and strip the classes directory as we need the module root $paths = array(substr($path, 0, -8)); // strip the namespace from the filename $file = substr($file, $pos + 2); } } else { $paths = $this->paths; // get extra information of the active request if (class_exists('Request', false) and $request = \Request::active()) { $request->module and $cache_id .= $request->module; $paths = array_merge($request->get_paths(), $paths); } } // Merge in the flash paths then reset the flash paths $paths = array_merge($this->flash_paths, $paths); $this->clear_flash(); $file = $this->prep_path($dir) . $file . $ext; $cache_id .= $file; if ($cache and $cached_path = $this->from_cache($cache_id)) { return $cached_path; } foreach ($paths as $dir) { $file_path = $dir . $file; if (is_file($file_path)) { if (!$multiple) { $found = $file_path; break; } $found[] = $file_path; } } if (!empty($found) and $cache) { $this->add_to_cache($cache_id, $found); } return $found; }