public function hasCollisions() { $this->collisions = array(); $this->namespace = AkInflector::underscore(Ak::first(explode(':', $this->task_name . ':'))); $this->task_name = AkInflector::underscore(Ak::last(explode(':', ':' . $this->task_name))); $this->destination_path = AK_TASKS_DIR . DS . $this->namespace; if (file_exists($this->destination_path . DS . $this->task_name . '.task.php')) { $this->collisions[] = Ak::t('%path already exists', array('%path' => $this->destination_path . DS . $this->task_name . '.task.php')); } return count($this->collisions) > 0; }
static function getResourcePathNameFor($name, $default = null) { $result = Ak::first(Ak::pick($name, AkConfig::getOption('resources_path_names', array('add' => 'add', 'edit' => 'edit')))); return empty($result) ? $default : $result; }
function ak_get_application_included_files($source_for = '') { $app_files = array(); foreach (get_included_files() as $k => $file) { if (strstr($file, AK_FRAMEWORK_DIR)) { continue; } $short_path = str_replace(AK_BASE_DIR, '', $file); if (strstr($file, AK_MODELS_DIR)) { $app_files['Models'][$k]['path'] = $short_path; if ($file == $source_for) { $app_files['Models'][$k]['original_path'] = $file; } } elseif (strstr($file, AK_COMPILED_VIEWS_DIR)) { $path = Ak::first(explode('.tpl.', str_replace(array(AK_COMPILED_VIEWS_DIR, '/compiled'), '', $file))) . '.tpl'; if (!in_array($path, array('/app/views/exception.tpl', '/app/views/_trace.tpl'))) { $app_files['Views'][$k]['path'] = $path; if ($file == $source_for) { $app_files['Views'][$k]['original_path'] = $file; } } } elseif (strstr($file, AK_CONTROLLERS_DIR)) { $app_files['Controllers'][$k]['path'] = $short_path; if ($file == $source_for) { $app_files['Controllers'][$k]['original_path'] = $file; } } elseif (strstr($file, AK_HELPERS_DIR)) { $app_files['Helpers'][$k]['path'] = $short_path; if ($file == $source_for) { $app_files['Helpers'][$k]['original_path'] = $file; } } } return $app_files; }
public function getOffset() { return Ak::first($this->paginator->getOffsetByPageId($this->getCurrent())) - 1; }
protected function _getLocaleForRequest(&$Request) { if (isset($Request->lang)) { $lang = $Request->lang; } else { $lang = $this->getNavigationLanguage(); } if ($url_locale = $this->getLangFromUrl($Request)) { $lang = $this->getLocaleFromAlias($url_locale); } if (!$this->_canUseLocaleOnCurrentRequest($lang, $Request)) { $lang = Ak::first($this->getPublicLocales()); } elseif (empty($lang)) { $lang = Ak::first($this->getPublicLocales()); } // This way we store on get_url_locale and on lang the value of $lang on // a static variable for accessing it application wide empty($url_locale) ? null : Ak::get_url_locale($url_locale); Ak::lang($lang); return $lang; }
function test_attachment_with_text_type() { $TestMailer =& new TestMailer(); $Mail =& $TestMailer->receive(file_get_contents(AK_TEST_DIR."/fixtures/data/action_mailer/raw_email13")); $this->assertTrue($Mail->hasAttachments()); $this->assertEqual(1, Ak::size($Mail->attachments)); $Attachment = Ak::first($Mail->attachments); $this->assertEqual("hello.rb", $Attachment->original_filename); }
public function test_attachment_with_text_type() { $TestMailer = new TestMailer(); $Mail = $TestMailer->receive(file_get_contents(AkConfig::getDir('fixtures') . DS . "raw_email13")); $this->assertTrue($Mail->hasAttachments()); $this->assertEqual(1, Ak::size($Mail->attachments)); $Attachment = Ak::first($Mail->attachments); $this->assertEqual("hello.rb", $Attachment->original_filename); }
/** * Get a models a model instance. Including and instantiating the model for us. * * This kinds mimics the ideal (new Model())->find() which does not exist on PHP yet. * * On Akelos we can do Ak::get('Model')->find(); */ static function get($model_name, $attributes = array()) { $model_name = Ak::first(Ak::import($model_name)); if (!empty($model_name)) { return new $model_name($attributes); } }
public function getAccountSubdomain() { return Ak::first($this->Request->getSubdomains()); }
private function _getGeneratorsInsidePath($path) { $generators = array(); if (is_dir($path)) { foreach (AkFileSystem::dir($path, array('files' => false, 'dirs' => true)) as $folder) { $generator = Ak::first(array_keys($folder)); if (strstr($generator, '.php') || is_file($path . DS . $generator)) { continue; } $generators[$path . DS . $generator . DS . $generator . '_generator.php'] = $generator; } } return $generators; }
public function getPluginHelperNames() { $handler = $this->_Handler; $handler->plugin_helpers = !isset($handler->plugin_helpers) ? 'all' : $handler->plugin_helpers; $helper_names = AkHelperLoader::addPluginHelper(false); // Trick for getting helper names set by AkPlugin::addHelper if (empty($helper_names)) { return array(); } elseif ($handler->plugin_helpers == 'all') { return $helper_names; } else { $selected_helper_names = array(); foreach (Ak::toArray($handler->plugin_helpers) as $helper_name) { $helper_name = AkInflector::camelize($helper_name); if ($path = Ak::first(array_keys($helper_names, AkInflector::camelize($helper_name)))) { $selected_helper_names[$path] = $helper_names[$path]; } } return $selected_helper_names; } }