本文整理汇总了PHP中Extension::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Extension::add方法的具体用法?PHP Extension::add怎么用?PHP Extension::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Extension
的用法示例。
在下文中一共展示了Extension::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public static function add()
{
parent::add();
self::$facebook_app_id = Installer::getComposerEvent()->getIO()->ask(":: enter your facebook app id: ", "[app_id]");
self::$facebook_api_secret = Installer::getComposerEvent()->getIO()->ask(":: enter your facebook app secret: ", "[app_secret]");
File::replaceContent(Installer::getRootDirConfig() . self::getConfigfile(), "[app_id]", self::getFacebookAppId());
File::replaceContent(Installer::getRootDirConfig() . self::getConfigfile(), "[api_secret]", self::getFacebookApiSecret());
File::addContent(Installer::getRootDirTheme() . "Includes/Footer.ss", "<% include FacebookLoginLink %>", "SilverStripe</a></small>");
Installer::getComposerEvent()->getIO()->write(":: added facebookconnect extension");
}
示例2: add_extension
public function add_extension()
{
if (!Visitor::current()->group->can("add_extension")) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to create extensions.", "extend"));
}
if ($_FILES['extension']['error'] == 4) {
Flash::warning(__("You forgot the extension file, silly!", "extend"), $_SESSION['redirect_to']);
}
if (empty($_POST['name'])) {
Flash::warning(__("Please enter a name.", "extend"), $_SESSION['redirect_to']);
}
if (empty($_POST['number'])) {
Flash::warning(__("Please enter a version number.", "extend"), $_SESSION['redirect_to']);
}
if (empty($_POST['compatible'])) {
Flash::warning(__("Please list the Chyrp versions you know to be compatible with this extension.", "extend"), $_SESSION['redirect_to']);
}
$type = new Type($_POST['type_id']);
$visitor = Visitor::current();
# Add the MIT license if no license is specified
$zip = new ZipArchive();
if ($zip->open($_FILES['extension']['tmp_name']) === true and $zip->locateName("LICENSE") === false) {
$header = "Copyright (c) " . date("Y") . " " . oneof($visitor->full_name, $visitor->login);
$mit = <<<EOF
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise
to promote the sale, use or other dealings in this Software
without prior written authorization.
EOF;
$zip->addFromString("LICENSE", $header . "\n\n" . $mit . "\n");
$zip->close();
}
$filename = upload($_FILES['extension'], "zip", "extension/" . pluralize($type->url));
$image = $_FILES['image']['error'] == 0 ? upload($_FILES['image'], null, "previews/" . pluralize($type->url)) : "";
$extension = Extension::add($_POST['name'], null, null, $type);
$version = Version::add($_POST['number'], $_POST['description'], comma_sep($_POST['compatible']), comma_sep($_POST['tags']), $filename, $image, 0, 0, $extension);
$files = array();
foreach ($_FILES['attachment'] as $key => $val) {
foreach ($val as $file => $attr) {
$files[$file][$key] = $attr;
}
}
foreach ($files as $attachment) {
if ($attachment['error'] != 4) {
$path = upload($attachment, null, "attachments");
Attachment::add(basename($path), $path, "version", $version->id);
}
}
Flash::notice(__("Extension added.", "extend"), $extension->url());
}
示例3: add
public static function add()
{
parent::add();
Installer::getComposerEvent()->getIO()->write(":: added bootstrap-forms extension");
}