protected function preExecute() { if (class_exists('waAutoload')) { waAutoload::getInstance()->add('Archive_Tar', '/wa-installer/lib/vendors/PEAR/Tar.php'); waAutoload::getInstance()->add('PEAR', '/wa-installer/lib/vendors/PEAR/PEAR.php'); } }
protected function init() { $autoload = waAutoload::getInstance(); foreach (array('uspsLabelsExpressMailQuery', 'uspsLabelsInternationalShippingQuery', 'uspsLabelsUspsTrackingQuery', 'uspsLabelsQuery', 'uspsLabelsSignatureConfirmationQuery', 'uspsQuery', 'uspsRatingsQuery', 'uspsServices', 'uspsTrackingQuery') as $class_name) { $autoload->add($class_name, "wa-plugins/shipping/usps/lib/classes/{$class_name}.class.php"); } parent::init(); }
<?php if (class_exists('blogBlogModel')) { $blog_model = new blogBlogModel(); } elseif (class_exists('waAutoload', false)) { waAutoload::getInstance()->add('blogBlogModel', 'wa-apps/blog/lib/models/blogBlog.model.php'); waAutoload::getInstance()->add('blogItemModel', 'wa-apps/blog/lib/models/blogItem.model.php'); $blog_model = new blogBlogModel(); } else { $blog_model = null; } return array('params' => array('blog_url_type' => array('name' => _w('Published blogs & URLs'), 'type' => 'radio_select', 'items' => array(-1 => array('name' => sprintf(_w('All blogs. Plain URLs (%s)'), '/post_url/'), 'description' => sprintf(_w('<br />Post URLs: <strong>%s</strong>, e.g. %s<br />Blog post list URLs: <strong>%s</strong>, e.g. %s'), '/post_url/', '/my-first-post/', '/blog/blog_url/', '/blog/misc/, /blog/family/')), 0 => array('name' => sprintf(_w('All blogs. Hierarchical URLs (%s)'), '/blog_url/post_url/'), 'description' => sprintf(_w('<br />Post URLs: <strong>%s</strong>, e.g. %s<br />Blog post list URLs: <strong>%s</strong>, e.g. %s'), '/blog_url/post_url/', '/misc/my-first-post/', '/blog_url/', '/misc/, /family/')), array('name' => _w('One blog'), 'description' => sprintf(_w('Post URLs: <strong>%s</strong>'), '/post_url/', 'none'), 'items' => $blog_model ? $blog_model->select('id,name')->where("status='" . blogBlogModel::STATUS_PUBLIC . "'")->fetchAll('id', true) : array()))), 'post_url_type' => array('name' => sprintf(_w('Post sub-URL format (%s)'), 'post_url'), 'type' => 'radio_select', 'items' => array(array('name' => _w('Post URL only'), 'description' => _w('e.g.') . ' /my-first-post/'), array('name' => _w('Year/post URL'), 'description' => _w('e.g.') . ' /2011/my-first-post/'), array('name' => _w('Year/month/post URL'), 'description' => _w('e.g.') . ' /2011/12/my-first-post/'), array('name' => _w('Year/month/date/post URL'), 'description' => _w('e.g.') . ' /2011/12/13/my-first-post/'))), 'title_type' => array('name' => _w('Title format'), 'type' => 'radio_select', 'items' => array('post' => array('name' => _w('Post title only'), 'description' => _w('e.g.') . ' <title>Post</title>'), 'blog_post' => array('name' => _w('Blog » Post title'), 'description' => _w('e.g.') . ' <title>Blog » Post</title>')), 'default' => 'blog_post'), 'title' => array('name' => _w('Homepage title'), 'type' => 'radio_text', 'description' => '', 'items' => array(array('name' => wa()->accountName(), 'description' => _ws('Company name')), array('name' => 'Задать явно')))), 'vars' => array('$wa' => array('$wa->blog->blog(<em>blog_id</em>)' => _w('Returns blog info by <em>blog_id</em> as an array with the following structure: (<em>"id"</em>, <em>"url"</em>, <em>"name"</em>, <em>"status"</em>, <em>"icon"</em>, <em>"qty"</em>, <em>"color"</em>, <em>"sort"</em>, <em>"icon_url"</em>, <em>"icon_html"</em>, <em>"link"</em>)'), '$wa->blog->post(<em>post_id</em>[,<em>fields</em>])' => _w('Returns post info by <em>post_id</em> as an array with the following structure: (<em>"id"</em>, <em>"contact_id"</em>, <em>"contact_name"</em>, <em>"datetime"</em>, <em>"title"</em>, <em>"text"</em>, <em>"status"</em>, <em>"url"</em>, <em>"blog_id"</em>, <em>"comments_allowed"</em>, <em>"user"</em>, <em>"comment_count"</em>, <em>"comment_new_count"</em>, <em>"plugins"</em>, <em>"icon"</em>, <em>"color"</em>, <em>"blog_status"</em>, <em>"blog_url"</em>, <em>"blog_name"</em>, <em>"link"</em>)'), '$wa->blog->blogs()' => _w('Returns the array of all public blogs. Each blog is an array presenting the blog data'), '$wa->blog->posts([<em>blog_id</em>[,<em>number_of_posts</em>]])' => _w('Returns the array of all posts by <em>blog_id</em>. If <em>blog_id</em> is <em>null</em>, the array of all public posts is returned. Optional parameter <em>number_of_posts</em> limits the number of elements returned')), 'index.html' => array('$content' => 'Core content loaded according to the requested resource: a blog post, post stream, a page, etc.'), 'stream.html' => array('$posts' => array('$id' => '', '$blog_id' => '', '$contact_id' => '', '$title' => '', '$text' => '', '$status' => '0 for published, 1 for deleted', '$datetime' => '', '$datetime_public' => '', '$url' => '', '$comment_count' => '', '$user' => '')), 'post.html' => array('$current_auth.source' => '', '$current_auth.source_id' => '', '$current_auth.url' => '', '$current_auth.name' => '', '$current_auth.firstname' => '', '$current_auth.lastname' => '', '$current_auth.login' => '', '$current_auth.photo_url' => '', '$current_auth_source' => '', '$auth_adapters' => '', '$theme' => '', '$post.id' => '', '$post.contact_id' => '', '$post.datetime' => '', '$post.title' => '', '$post.text' => '', '$post.user' => '', '$post.comments' => array('$id' => '', '$post_id' => '', '$contact_id' => '', '$text' => '', '$datetime' => '', '$name' => '', '$email' => '', '$status' => '', '$depth' => '', '$parent' => '', '$site' => '', '$auth_provider' => '', '$ip' => '', '$user' => '', '$new' => ''), '$post.comment_count' => '', '$post.comment_new_count' => '')), 'blocks' => array('latest_posts' => array('description' => _w('Latest blog posts'), 'content' => ' <style> .post { margin-bottom: 80px; margin-right: 50px; } .post h3 { font-size: 2em; margin-right: 5px; margin-bottom: 3px; } .post .credentials { color: #AAA; font-size: .9em; margin-bottom: 5px; } .post .username { color: #777; padding: 0; display: inline; } </style> {$latest_posts = $wa->blog->posts()} <div> {foreach $latest_posts as $post} <div class="post"> <h3> <a href="{$post.link}">{$post.title}</a> {* @event prepare_posts_frontend.%plugin_id%.post_title *} {if !empty($post.plugins.post_title)} {foreach $post.plugins.post_title as $plugin => $output}{$output}{/foreach} {/if} </h3> <div class="credentials"> {if $post.user.posts_link}
public function init() { $files = array($this->getAppPath() . '/lib/config/config.php', $this->getPath('config') . '/apps/' . $this->application . '/config.php'); foreach ($files as $file_path) { if (file_exists($file_path)) { $config = (include $file_path); if ($config && is_array($config)) { foreach ($config as $name => $value) { $this->options[$name] = $value; } } } } $this->info = (include $this->getAppPath() . '/lib/config/app.php'); if ($this->environment == 'backend' && !empty($this->info['csrf']) && waRequest::method() == 'post') { if (waRequest::post('_csrf') != waRequest::cookie('_csrf')) { throw new waException('CSRF Protection', 403); } } waAutoload::getInstance()->add($this->getClasses()); if (file_exists($this->getAppPath() . '/lib/config/factories.php')) { $this->factories = (include $this->getAppPath() . '/lib/config/factories.php'); } if (!empty($this->options['factories']) && is_array($this->options['factories'])) { foreach ($this->options['factories'] as $k => $v) { $this->factories[$k] = $v; } } }
/** * Relative path from app root to plugin root this controller belongs to * (no leading slash, with trailing slash). For application controllers return ''. * @return string relative path or '' */ public function getPluginRoot() { $path = waAutoload::getInstance()->get(get_class($this)); if (!$path) { return ''; } // Remove path to application from path to a controller to get relative path $appsPath = str_replace('\\', '/', waConfig::get('wa_path_apps')); $path = dirname($path); $path = str_replace('\\', '/', $path); if (false === strpos($path, $appsPath)) { // webasyst app $appsPath = str_replace('\\', '/', waConfig::get('wa_path_system')); if (false === strpos($path, $appsPath)) { return ''; } } $path = str_replace($appsPath, '', $path); $path = trim($path, '\\/'); $path = preg_replace('~^[^/]+/~', '', $path); // remove app dir from the begining of the path // /lib dir indicates that we've found either a plugin root or an application root $prevBase = ''; while ($prevBase != 'lib') { $prevBase = basename($path); $path = dirname($path); if (!$path || $path == '.') { return ''; } } return $path . '/'; }
/** * * Compress theme into archive file * @param string $path target archive path * @param string $name archive filename * @return string arcive path */ public function compress($path, $name = null) { if (!$name) { $name = "webasyst.{$this->app}.theme.{$this->id}.tar.gz"; } $target_file = "{$path}/{$this->app}/{$name}"; $autoload = waAutoload::getInstance(); $autoload->add('Archive_Tar', 'wa-installer/lib/vendors/PEAR/Tar.php'); $autoload->add('PEAR', 'wa-installer/lib/vendors/PEAR/PEAR.php'); if (file_exists($this->path) && class_exists('Archive_Tar', true)) { waFiles::create($target_file); $tar_object = new Archive_Tar($target_file, true); $tar_object->setIgnoreRegexp('@(\\.(php\\d?|svn|git|fw_|files\\.md5$))@'); $path = getcwd(); chdir(dirname($this->path)); if (!$tar_object->create('./' . basename($this->path))) { waFiles::delete($target_file); } chdir($path); } return $target_file; }
<?php require_once dirname(__FILE__) . '/../wa-system/autoload/waAutoload.class.php'; waAutoload::register(); class SystemConfig extends waSystemConfig { }
/** * Unregister waAutoload from spl autoloader. * * @return void */ public static function unregister() { spl_autoload_unregister(array(self::getInstance(), 'autoload')); self::$registered = false; }
protected function init() { $autload = waAutoload::getInstance(); $autload->add("IShopServerWSService", "wa-plugins/payment/qiwi/vendors/qiwi/IShopServerWSService.php"); $autload->add("IShopClientWSService", "wa-plugins/payment/qiwi/vendors/qiwi/IShopClientWSService.php"); $autload->add("nusoap_base", "wa-plugins/payment/qiwi/vendors/nusoap/nusoap.php"); return parent::init(); }
<?php $al = waAutoload::getInstance(); $al->add('xmlrpc_client', 'wa-apps/blog/plugins/import/vendors/xmlrpc/lib/xmlrpc.php');
<?php require_once dirname(__FILE__) . '/../wa-system/autoload/waAutoload.class.php'; waAutoload::register(); waAutoload::getInstance()->add(array('myRouting' => 'wa-apps/warehouse/lib/site/myRouting.class.php', 'siteConfig' => 'wa-apps/site/lib/config/siteConfig.class.php', 'mySiteConfig' => 'wa-apps/warehouse/lib/site/mySiteConfig.class.php', 'myFrontController' => 'wa-apps/warehouse/lib/site/myFrontController.class.php', 'mySiteFrontendController' => 'wa-apps/warehouse/lib/site/mySiteFrontend.controller.php', 'mySiteFrontendLayout' => 'wa-apps/warehouse/lib/site/mySiteFrontendLayout.class.php', 'siteFrontendSidebarAction' => 'wa-apps/warehouse/lib/site/siteFrontendSidebar.action.php')); class SystemConfig extends waSystemConfig { public static function getAppConfig($application, $environment = null, $root_path = null, $locale = null) { //hook creating app's config and create proxy config over siteConfig if ($application == 'site') { if ($root_path === null) { $root_path = realpath(dirname(__FILE__) . '/..'); } if ($environment === null) { $environment = waSystem::getInstance()->getEnv(); } return new mySiteConfig($environment, $root_path, $application, $locale); } return parent::getAppConfig($application, $environment, $root_path, $locale); } }